这是一个stata的题目,怎么做呀

题目是英语的,教育和婚姻变量没labels,请根据下边副本里的价值标签给教育和婚姻贴上标签

The variables –​education​– and –​married​– are numeric but do not have value

labels, yet. Label the values of the two variables according to those given below

in the Appendix.

Value labels
–​married​–:
1 - married
2 - not married
–​education​–: 1 - tertiary
2 - unfinished tertiary
3 - special secondary
4 - secondary
5 - 7 years of schooling 6 - primary
7 - can read and write 8 - can read
9 - illiterate
10 - child aged 0-8 99 - missing value

cd /Victor/stata

//二

//1.a

sysuse "auto.dta",clear

foreach num of numlist 1/74{

export excel using "auto`num'.xlsx" in `num'

}

//1.b

foreach num of numlist 1/74{

import excel "auto`num'", clear

save "auto`num'.dta", replace

}

//将excel转换成dta格式

use "auto1.dta",clear

foreach num of numlist 2/70{

append using "auto`num'.dta"

}

save "auto_new.dta", replace

//1.c

foreach num of numlist 1/74{

erase "auto`num'.xlsx"

}

//2(因为我的stata软件无法识别跨行命令,只能一长串写在一行)

use "auto_new.dta",clear

twoway(scatter weight mpg if foreign == 0, mcolor(navy blue) msymbol(x)) (scatter weight mpg if foreign == 1, mcolor(red))  , legend(on order(1 "foreign" 2 "domestic")  ring(0)) title("The Relatonship between Car Weight and MPG") ylabel(1000 2000 3000(2000)5000) xlabel(10(5)35)

//3

sysuse "nlsw88.dta",clear

tabstat wage hours ttl_exp tenure ,by(union) stat(n mean sd min median) c(s)

//4

sysuse "nlsw88.dta",clear

order wage hours ttl_exp tenure collgrad

foreach v of varlist wage-collgrad{

ttest `v',by(union)

}

//5

sysuse "nlsw88.dta",clear

reg wage age race industry occupation ttl_exp hours

ssc install logout

logout, save(result_2017302330037.xlsx) excel dec(3) replace:reg wage age race industry occupation ttl_exp hours

//三

sysuse "firm.dta",clear

sort ID date ipc patent_ID

//2

replace firm_name = subinstr(firm_name, "有限责任公司"," ",.)   

replace firm_name = subinstr(firm_name, "集团股份有限公司"," ",.)

replace firm_name = subinstr(firm_name, "股份有限公司"," ",.)

//3

//计算每个企业每年专利数量总和

use "firm.dta",clear

encode patent_ID ,gen(patent_ID1) 

bys ID date : egen num_patent=count(patent_ID1)

//计算不重复的领域数

duplicates drop ID date ipc,force

bys ID date: egen ipc_sum=count(ipc)


温馨提示:答案为网友推荐,仅供参考
第1个回答  2019-03-15
label命令比较简单的
相似回答