Re: separating string variables for pregnancy complication questions [message #11680 is a reply to message #11679] |
Fri, 27 January 2017 03:41 |
schoumaker
Messages: 66 Registered: May 2013 Location: Belgium
|
Senior Member |
|
|
Hello,
The few lines below will create new dichotomous variable (Q406_A, q406_B,...). There may be other ways to do this, but this should work.
Best,
Bruno
***
local resp "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"
foreach var of local resp {
gene q406_`var'=1 if regexm(q406,"`var'")==1
replace q406_`var'=0 if regexm(q406,"`var'")!=1 & q406!=""
}
Bruno Schoumaker
Centre for Demographic Research
Université catholique de Louvain
|
|
|