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
Petersen 2009 - Estimating standard errors in panel data setsHello all, I'm having some trouble at replicating this paper Peterson 2009 and have simulation.do f…
Multiple variables using grmapDear all, I am working with the command grmap, and I have no problems in creating maps. However, I …
Matching based on propensity score taking care of yearDear statalisters I'm facing with a lot of difficulties to implement matching with propensity scores…
Help with Estout table showing 3 values vertically, in 3 rowsHi, I am trying to get my table to look like the following in a .tex file, using estout. This shows…
Calculate a new variable using values of a country´s region excluding the country being mesuredHello, I would like to create a new variable that is an average (weekly) of the "stringency" (examp…
Subscribe to:
Post Comments (Atom)
0 Response to Generating dummy variables using non-numerical data
Post a Comment