Hello. I am working with survey data where participants are asked if they agree with a statement, in this case whether they consider themselves a public servant. They can choose between five answers. I would like to create a dummy variable PublicServant where 1 = yes and 0 = all other answers. I am not used to working with non-numerical answers and am unsure of the syntax needed. Do I use quotation marks around the potential answers? Is there a way to consolidate this code and say 1=yes and 0=all other answers?
This is my drafted code but I get a mismatch error:
gen publicservant=.
replace publicservant=0 if PublicServant=="[2] No"
replace publicservant=0 if PublicServant=="[3] Don't Know"
replace publicservant=0 if PublicServant=="[-1] No answer"
replace publicservant=1 if PublicServant=="[1] Yes"
replace publicservant=0 if PublicServant=="[-2] Does not Apply"
Related Posts with Generating dummy variables using non-numerical data
Help with instrumental variable regressionHello everybody, I need your help please. I have a dummy variable which is potentially endogenous. …
Translate R to STATAHello, I would like to translate this R formula below in Stata. My data : translate <- contains…
Stata -system run out of application memoryHi all, I am running a do file on Stata that generates a set of quite large tempfiles (one is around…
Interpretation of interaction effect with -margins-I'm currently researching the effect of gender on the performance of microfinance institutions (MFI)…
nesting cond()hi All, I was reading the stata journal version: The Stata Journal (2005) 5, Number 3, pp. 413–420 …
Subscribe to:
Post Comments (Atom)
0 Response to Generating dummy variables using non-numerical data
Post a Comment