-《用Stata學(xué)計(jì)量經(jīng)濟(jì)學(xué)》
use:打開一個(gè)已存的Stata數(shù)據(jù)(.dta)文件臂港,可以是文件名也可以是詳細(xì)地址;ex:use "xxxxx" or "D:\xx\xxx\xxx(.dta)"?;use [varlist] [if] [in] using filename [, clear nolabel]
_N與_n:_N表示觀測(cè)值總數(shù)誉简;_n表示當(dāng)前的觀測(cè)值序號(hào)
generate(gen):產(chǎn)生并命名一個(gè)新變量,且要求是未存在的; generate [type] newvar[:lblname] =exp [if] [in] [, before(varname) |
? ? ? ? ? ? ? ? after(varname)]
replace:改變一個(gè)已有變量數(shù)據(jù); replace oldvar =exp [if] [in] [, nopromote]
sort:排序盟广,sort varlist [in] ?[, stable]
gsort:只產(chǎn)生升序排序闷串;gsort [+|-] varname [[+|-] varname ...] [, generate(newvar) mfirst]
if exp:條件命令;ex:gen n = x if pop>500()新建一個(gè)n變量筋量,當(dāng)變量pop的值大于500時(shí)n時(shí)將x的值賦予n烹吵,若不滿足條件則為缺失值 ?注:x與pop已經(jīng)存在)這里的“pop>500”就是exp
lables:給變量添加標(biāo)簽
notes:給變量添加注釋
*:通配符碉熄,*pop表示以“pop”結(jié)尾的所有變量名(已存在),如smallpop肋拔,largepop都屬于
drop: 刪除變量锈津,drop varlist
keep:保留變量,keep varlist
rename:重命名凉蜂,rename old_varname new_varname
renpfix:重命名多個(gè)變量,renpfix income inc,(把incom80與income81改為inc80和inc81)琼梆,其中的incom和inc都只是變量的一部分前綴
save:保存數(shù)據(jù),一般操作的修改都只是在內(nèi)存上窿吩,save可將數(shù)據(jù)保存到硬盤茎杂,下次亦可使用