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
Mediation Analysis in stata with non continuous mediator- Test statistics?Dear all, I need to run two mediation analysis for a research project and after having studied the …
Testing Replication Code + Best PracticeI am preparing my replication files for an article that has been accepted subject to replication che…
Subsample in Panel data By MedianHello all, I have another question and hopefully you can help me (as already done several times) I a…
mixed with 2 time pointsHi, I am trying to build a random intercept/random slope model with longitudinal data (time is nest…
Trouble with repeated dates and panel creationHi all, I have the following issue, I want to create a panel out of data that contains a code (the p…
Subscribe to:
Post Comments (Atom)
0 Response to Changing yes/no observations into 1/0
Post a Comment