如图,分类用的A B C D等字符串形式表示的。我想把它转换为1 2 3 4等数值类型表示的。
我想的比较笨的办法就是一次生成type1 type2...typen,
gen type=1 if type==“A”
replace type1=0 if type1==. (原因是不等于A的生成的为缺漏值) 但是这一步stata说有问题,返回值是109: In an expression, you attempted to combine a string and numeric
subexpression in a logically impossible way.