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
dropping constant in a fixed effects modelDear Statalist members, I just wanted to check if there is a way I can specify a fixed effects mode…
Decode halfyearly date strings for Panel DataDear Statalist community, I have a problem with my time variable is recognized as a string when I do…
Unintelligible code in Stata 16Dear Stata users, I use community-contributed command -tabout- (SSC, written by Ian Watson) to expor…
The use of the symbol $ in Stata commandsHi Statalist In many of the questions posted, the following syntax has been used: e.g. $covariates …
spmat import dataDear all, i am unable to import data as a spatial weight matrix into Stata using spmat. The data a…
Subscribe to:
Post Comments (Atom)
0 Response to Changing yes/no observations into 1/0
Post a Comment