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
Command stir does not accept iweightsHello I've been using the command stir (incidence rate comparison). The manual says that stir allows…
Replace if not found within a loopDear all, I am trying to bottom and top coding the household income for each country - wave. I am us…
endogenous switching regression modelHello, Please I am new in stata so it's quite difficult for me to solve some regression problems. A…
-dstdize- to calculate average age-adjusted death rate by raceGood Morning, I would like to calculate the average age-adjusted death rate by race (separately for…
ci for categorial variables - tabci?I'm just wondering why Stata gives CIs for binary variables - ci proportions varname - but, as far a…
Subscribe to:
Post Comments (Atom)
0 Response to Changing yes/no observations into 1/0
Post a Comment