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
Dividing Variable by its meanDear all, I have question regarding to my independent variable and interpretation of it. I have di…
Displaying the number of observationsDear statalist, While running a logistic regression, is it possible to display the number of observ…
Plausible values: what do i do?Hi, i have found nearly nothing on this. It is used mostly on PISA, TIMMS and PIRLS testing. I kind …
mi impute for two variablesHi, I am trying to impute two separate variables. When trying to determine an appropriate imputatio…
Shea’s partial R squaredHi, I am trying to check the relevance of instruments used in 2SLS regression. I use Shea’s partial…
Subscribe to:
Post Comments (Atom)
0 Response to Generating dummy variables using non-numerical data
Post a Comment