1、把中文字符重编码stata命令: egen code_new = group(code)
2、PSM 运行不出结果:减少协变量 或者减少连续的协变量 连续的协变量匹配特别慢
3、psm匹配时出现,outcome does not vary; remember:
0 = negative outcome,
all other nonmissing values = positive outcome
此时可能是处理变量不是0或1,处理变量取应该是0或者1.
4、stata生成虚拟变量的方式:
(1)双类别虚拟变量,顾明思议就是将变量分成两类进行虚拟变量的生成。如性别等等。我们还是打开我们的老朋友auto.dtasysuse auto gen d=(length>200) 这样就可以生成一个双分类虚拟变量,也就是>200的是一个小于等于200的是一个。 (2)多类别虚拟变量.第一步 生成分类变量: gen group=0 第二步 改变赋值 replace group=1 if regexm(t,"-03-") replace group=2 if regexm(t,"-06-") replace group=3 if regexm(t,"-09-") replace group=4 if regexm(t,"-12-") tab group,gen(season) 注:t是要处理的变量,“”里面是t的具体取值,字符 5、生成变量标签 gen group=0 replace group=1 if happy=="非常幸福" replace group=2 if happy=="幸福" | happy=="一般" |