I am using Stata 15 MP
My questionnaire dataset: obs: 7,153 vars: 1,714 size: 26,938,198
I have variables that are incorrectly coded. They have missing instead of 'Not answered'
I need therefore to use a completion variable to recode the missings into not answered and truly missing.
So variables:
xz3001 (and others) Coded 0=no 1=once 2=two times 3=three times .=missing
xza Numeric (int) Age in months at completion range [1137, 1166] unique values: 25 Missing 1,141 examples: 1140 1140 1141 1143
I have tried generating a dummy variable and recoding very many ways and am getting stuck each time. I have gotten to as below but it is not working. What am I coding wrongly?
foreach item of varlist xz3001 xz3101 xz3201 xz3301 {
gen notimes_`item'=xza
replace notimes_`item'=`item' if xza>0.5
replace notimes_`item'=. if xza==.
replace notimes_`item'=0 if xza>0.5&`item'>0.5
_crcslbl notimes_`item' `item'
tab `item',miss
tab notimes_`item',miss
tab notimes_`item' xz,miss
}
Related Posts with Problem with missing/ sample n for derived variables
Establishing parallel trends in a probit differences-in-differences modelHi, I have a question that's slightly more conceptual than related to direct stata output. I unders…
generate an identifier variable that changes with every 3 observations?Hi folks. I have a dataset of this form: Code: * Example generated by -dataex-. To install: ssc in…
Interpreting Logit transformation of dependent variableHello all, In my master thesis I am using difference and system gmm. The problem is that the depende…
Codes for cross sectional dependence tests (i.e. Baltagi (2012); Biased-adj LM (Pesaran et al., 2006) Pesaran CDLMPlease, let me know what are the commands to run Baltagi et al. (2012) CD, Bias-adjusted LM test (Pe…
problem with legendUsing the below codes, I could create three graphs and combine them into one nice graph. As shown in…
Subscribe to:
Post Comments (Atom)
0 Response to Problem with missing/ sample n for derived variables
Post a Comment