Hello,
I am trying to create a loop for a large cross-sectional dataset that identifies string variables with the response options "Yes; No; or, Unknown", replaces these values with "1, 0, or, -1", and destrings them. Preferably I would like to replace the original string variable rather than generate duplicate numeric variables. Do I have to go through the entire dataset and identify each variable name to add to a local varlist or can I set a conditional statement and loop over all the variables?
Thank you,
Tom
Related Posts with foreach loop based on whether variable has certain values
How to display the mean on a graph pieHello. Is there a way to display the mean when I create a graph pie ? My current code is Code: g…
Need help with combining plots and figuresI need help with the following issues: 1. Combining Plots I have the following syntax for my plots:…
Case-crossover design and predictive performanceHi all, Thank you in advance for your comments and suggestions! We are conducting a case-crossover…
How to change a trinary variable into a binary with label in 1 lineHello. I have to recode a trinary variable "a6a" : 1=small, 2=medium, 3=large. Into a binary variab…
plot hazard ratio and confidence intervalsGood morning, I have a basic question. I'm starting with stata running a cox model xi:stcox i.terti…
Subscribe to:
Post Comments (Atom)
0 Response to foreach loop based on whether variable has certain values
Post a Comment