变量转换 encode sex,generate(gender)//生成数值型变量gender decode gender,generate(gender2)//根据gender变量重新生成一个字符型变量gender2 recode x2(1 2=1)(3=2)(4/7=3),gen(nx2)//改变x2的赋值,由1和2变为1,将3改为2,将4到7改为3并将新的结果保存在nx2 gen exper1=autocode(exper,5,1,51)//表示根据x值形成分类变量:将exper的值域(即最小值1至最大值51)分成等距的5份,并求出各x值所在区间的上限 gen exper2=group(5)//建立一个分类变量,将按排序后的数据分为尽量等规模的5个子样本 gen exper3=recode(exper,5,15,25,40,51)//当x缺失时求得缺失值,当exper<5时求得5,当exper<15时求得15
标签:转换,变量,gender,51,STATA,exper,recode,gen From: https://www.cnblogs.com/xkdn/p/17151578.html