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
Cleaning data of Globar Entrepreneurship MonitorDear All, I am currently dealing with cross-sectional studies derived from the Global Entrepreneurs…
Survey dataGood morning I need some advice for my master thesis please. My data is a cross-sectional survey. A…
Roc curve after beta regressionHi everyone, I want to perform Roc analysis after beta regression and fractional regression. I have …
tebalance summarize coefplotHi everyone, I am working (still in process on the matching model) on a project using teffects psma…
Sample selection for a panel: struggling with panel bootstrap in the programDear Statalisters, I am using Stata 15.1 and I would like to address the sample selection problem i…
Subscribe to:
Post Comments (Atom)
0 Response to Problem with missing/ sample n for derived variables
Post a Comment