原始变量 hatlev1d 是文字型 str 变量,内容只有 L, M, H 和 9.
*-产生一个新的数值变量:
gen hatlev_123 = 1 if hatlev1d =="L"
replace hatlev_123 =2 if hatlev1d =="M"
replace hatlev_123 =3 if hatlev1d =="H"
replace hatlev_123 =9 if hatlev1d =="9"
*-定义“数字-文字对应表”
label define hatlev_123 1 "Low: Lower secondary" 2 "Medium: Upper secondary" 3 "High: Third level" 9 "Not applicable (child less than 15 years old)"
label value hatlev_123 hatlev_123
labelbook hatlev_123 // 查看数字文字对应表
本文来自: 人大经济论坛 统计软件培训班VIP答疑区 版,详细出处参考:
https://bbs.pinggu.org/forum.php? ... 1&from^^uid=40938