ex6.do

備忘用的 ex6.do (Stata)

*利用cd指定資料所在之工作目錄
cd c:\data\

*用insheet指令讀取文字檔資料
insheet using ex6.txt, clear

*用label data 來為資料檔命名
label data “2003期中考成績”

*用label var 來為變數命名
label var sn “serial number”
label var classyr “年級”
label var gender “性別”
label var depart “科系”
label var h1 “作業一成績”
label var h2 “作業二成績”
label var h3 “作業三成績”
label var h4 “作業四成績”
label var stat “統計成績”
labe var lab “電腦操作成績”

label define gender 1 “male” 0 “female”
label value gender gender

generate female = 1 if gender==0
replace female = 0 if gender==1

label define female 1 “女性” 0 “男性”
label value female female

drop if sn==.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: