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
Work without shapefileHi to everyone. I state that I am new to Spatial Econometrics. My data set is composed of 32 gasolin…
Panel data with lagged independent variables and dependent variable only two periodsHi Member, Please, does anyone could help me? I need to lag and lead one independent variable in my …
Problem with -replace- var ... if ... I was suprised to see that the last two commands ("replace new_var = 0 [...] and replace new_var = …
Firm, industry and event fixed effects in a regression modelI am doing an event study on the impact of ESG on stock returns. I have performed the event study it…
qregsel implementationDear members Am implementing the recommendations in this paper https://www.stata.com/meeting/us20/s.…
Subscribe to:
Post Comments (Atom)
0 Response to Problem with missing/ sample n for derived variables
Post a Comment