计量代码

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

/*

============================================================= =============

* Program: Econometrics TA - Stata Demo

* Description: Basic Stata code

* Version:

* 1.Sep/2012 by G.M.Zeng

* 2.Sep/2015 by Wanru Xiong

* 3.Sep/2017 by Chen Zihao

*

============================================================= ============= */

/*****************0.Gate keeping code******************************/ clear all/*Remove everything from the memory, refresh.

cap log close/*Close any open log file.

set more off/*Show the result all at once.

**set more on /*Show the result section by section.

cd "C:/课件/17秋计量/Stata_0923"

/*更改当前路径为。。。Specify working directory (cd: change directory)

/*Manually: File --> change working directory

**pwd

/*显示当前路径Displays the path of the current working directory.

log using demo.txt,replace/*打开demo.txt文件,覆盖原来日志

/*****************HELP!******************************************/ help log /*查看命令的详细说明

/**********1.Import & save data*******************************/

/*--Import.1--*/

use wage.dta, clear/*清空内存数据,打开wage.dta的数据Import .dta format (Stata data format)*/

insheet using wage.csv,clear/*加载.csv format*/

import excel using wage.xlsx, first clear /*Import .xlsx format*/

browse/*打开数据看数据*/

edit/*Edit data.

/*--Import.2--*/

/*Or copy paste in Data Editor.

/*Advance: merge / append

/*--Save.1--*/

save wage_1.dta,replace/*Save data, replace the original file. /*--Save.2--*/

/*Or copy paste

/***outfile

/***************2.Desribe the data*********************************/

/*--basic info.1--*/

describe/*每一个变量的含义View what is in the storage

d wage/*View a certain var; d is an abbreviation of "describe"*/

/*--basic info.2--*/

codebook/*View basic info of each var

codebook wage/*View basic info of a certain var

/*--basic info.3--*/

sum wage/*Summary statistics of a variable (Notice:missing value excluded)

sum wage, detail

Percentiles 显示了从1%到99%的分位数的取值。第二列是最小和最大的5个数。第三列从上到下:obs观测值数目、mean平均数、std.dev标准差、variance方差。skewness偏度: 偏度的绝对值越小,表明该数据的正态对称性越好。kurtosis峰度: 峰度值越大表明该数据的正态峰越明显。

return list/*View what are in the storage

scalar wage_avg = r(mean)/*赋值Get mean wage, save it as a scalar

scalar wage_max = r(max)/*Get max wage, save it as a scalar

dis wage_avg/*显示值Display the scalar

dis wage_max

/*? Exercise: Show the sample size and store it as a scalar called "sample_size"

/*--basic info.4--*/

tabstat educ, stat(mean min max)/*Show certain statistics of a var, more flexible than sum

tabstat educ, stat(mean min max) by(urban)/*Show certain statistics of a var by group

相关文档
最新文档