Hello Statalist, I have a particularly unique, perhaps esoteric question.
I am attempting to create some rules to recode some variables based on a string where there was a maximum of 3 responses allowed, and I have -split- the var which generated 3 new variables (var1, var2, var3). So ideally, if someone responded any combination of numbers as well as the number 5, I would want to recode the "5" to a missing.
So if, for example, someone responded "2, 4, 5", I would replace the var3 response of "5" to a "." but this gets quite burdensome with how many combinations there are. If there had been only two responses allowed, it would be quite easy to do "replace var2 = . if var == "1,5" and then repeat for "2,5" and "3,5" and "4,5".
But I've become curious if there is a way to just indicate "any#, 5" ... perhaps "?,5" or something like that (although I know that specifically will not work).
Thank you in advance for any insight!
Related Posts with Recoding rules based on string variable
discrete-time survival analysis xtcloglog late entryDear members, I am running a discrete-time survival analysis on an unbalanced panel data by using x…
Convert tex numeric variable without value label to string variableHi Statalisters, I have a basic question. I want to convert variable "srcdate" from numeric to stri…
Regression discontinuity design - discrete running variableI am conducting a sharp RD, with my running variable being the age of the woman in months. I am tryi…
Calculating cost of equity through fama and french 3 factor modelHello, I have to calculate the cost of equity capital based on fama and french 3 factor model. For …
Factor not found in list of covariatesHello, I have tried searching for an answer to my question but have not be able to find one. I am r…
Subscribe to:
Post Comments (Atom)
0 Response to Recoding rules based on string variable
Post a Comment