Hi all,
I tried searching for this and I just can't find the exact answer. It seems like this should be easy, but I just can't get it to work.
I want to create a new variable that is based off existing data, but only when it has certain data in a different variable. For example, I have a "countryID" variable that assigns a number depending on which country the data came from.
So if I want to create a new variable that only has data from USA (and that is coded "1" in CountryID) how would I do this? Is there a type of "when" command that could help? I couldn't find one.
I tried:
generate USAOnly = CountryID=1
Thank you!
Related Posts with Generate New Variable Only For Certain Data
Fixed effect ordered logitHi Stata users, I have an ordered dependent variable and I am trying to implement fixed effect orde…
Merging/Appending excel datasetHi everyone! So I need to import a new variable 'x' from an excel dataset (ED) within a Stata datase…
Frequency table for logistic regressionI'm running a multi-level miseducating effect logistic regression. I know that STATA will remove any…
ODBC, *Stata 16 and Big SurHello, After updating to MacOS BigSur 11.1.3, i am now facing the following problem with Stata 16 a…
Simulation generating the exact same data.Dear All, I am running a computationally intensive simulation on Stata-16 MP-32 core on a high-powe…
Subscribe to:
Post Comments (Atom)
0 Response to Generate New Variable Only For Certain Data
Post a Comment