I have a list of variables that contain answers Yes and No, I am trying to replace them with 1 and 0 and make all of them numeric
The command that I use is the following:
foreach var in MY LIST OF VARIABLES {
replace `var' = 0 if `var'==`No'
replace `var' = 1 if `var'==`Yes'
destring `var', replace
}
Stata responds "no variables defined". I would appreciate your help on this.
Thank you in advance!
Related Posts with Changing yes/no observations into 1/0
Pre-treatment effect interpretationHello, I have a quick question regarding the pre-treatment effect and I would appreciate to get an …
Hsiao Li Racine test for correct specification of parametric regression modelsHello, I am searching but have no luck in finding the stata code for the Hsiao Li Racine test that c…
How to determine if variables are statistically different (using t-test)?Hi all, I have one more question regarding my regression analysis in the housing market. I have ge…
Standardising variables ***Stata newbie***Hi all, I am trying to standardise 'ethnicity' variable into four categories: 1. white 2. black 3.…
Region and year fixed effects model for pooled cross sectional dataDear all, I have a dataset of pooled cross sectional data for individuals across a number of differ…
Subscribe to:
Post Comments (Atom)
0 Response to Changing yes/no observations into 1/0
Post a Comment