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
keep observations between the same rangeHi statalists, I have two variables, period and company. Period is the accumulative number of quart…
Using MatchitHi, I'm trying to merge two datasets based on a string variable; but the string variables don't matc…
SEM and nonlinear regressionHello everyone. Earlier, I used 'Stata' to build non-linear regressions. Recently, I started using …
Interactions between two variables with time-varying effects in flexible parametric survival analysis stpm2I am running a flexible parametric survival model using stpm2. In my data, I have two variables tha…
Is there a way in Stata to drop cases if the percentage of missing is greater than certain value according to key variable?Array Hi all! I want to drop cases if the percentage of missing is greater than certain value accord…
Subscribe to:
Post Comments (Atom)
0 Response to foreach loop based on whether variable has certain values
Post a Comment