Hello Statalist,
I am recoding text responses to a survey question and I would like to tell Stata to recode answers starting with "Demi" to a particular category. I am not sure how to do this with string variables. I have successfully done this before with string variables using a command like this "destring v*, force replace", but do not know how to do this with the contents of the variable.
Below is an example of the piece of code I am struggling with:
I am also curious if there is an easy way to tell Stata to ignore capitalization? For example, I have responses such as "Agender" and "agender" that I want to recode to the same category.
Thanks,
Laura
I am recoding text responses to a survey question and I would like to tell Stata to recode answers starting with "Demi" to a particular category. I am not sure how to do this with string variables. I have successfully done this before with string variables using a command like this "destring v*, force replace", but do not know how to do this with the contents of the variable.
Below is an example of the piece of code I am struggling with:
Code:
replace gendercatx=5 if dem_genderid_6_TEXT=="Genderfluid" | dem_genderid_6_TEXT=="Demi+" | dem_genderid_6_TEXT=="genderfluid"
Thanks,
Laura
Comment