通过STATA对多选题进行哑变量赋值方法
(2016-05-05 23:10:14)1、产生对应的哑变量
gen 政策保障1=0
gen 政策保障2=0
gen 政策保障3=0
gen 政策保障4=0
gen 政策保障5=0
gen 政策保障6=0
gen 政策保障7=0
gen 政策保障8=0
gen 政策保障9=0
2、将数值型变量转换成字符型
tostring 您期待政府部门在哪些方面能够给您和您的家庭提供更好的政策保障, generate(v1)
3、进行哑变量赋值
replace 政策保障1=1 if regexm(v1 ,"1")==1
replace 政策保障2=1 if regexm(v1 ,"2")==1
replace 政策保障3=1 if regexm(v1 ,"3")==1
replace 政策保障4=1 if regexm(v1 ,"4")==1
replace 政策保障5=1 if regexm(v1 ,"5")==1
replace 政策保障6=1 if regexm(v1 ,"6")==1
replace 政策保障7=1 if regexm(v1 ,"7")==1
replace 政策保障8=1 if regexm(v1 ,"8")==1
replace 政策保障9=1 if regexm(v1 ,"9")==1
drop 您期待政府部门在哪些方面能够给您和您的家庭提供更好的政策保障 v1