The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Topics » Reproductive Health » separating string variables for pregnancy complication questions
Re: separating string variables for pregnancy complication questions [message #11680 is a reply to message #11679] Fri, 27 January 2017 03:41 Go to previous messageGo to previous message
schoumaker is currently offline  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
 
Read Message
Read Message
Read Message
Previous Topic: DECOMPOSING ERREYGERS CONCENTRATION INDEX - STATA...
Next Topic: STATA recode for assistance during delivery SLDHS
Goto Forum:
  


Current Time: Wed Jan 15 01:53:42 Coordinated Universal Time 2025