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
What kind of a binary regression model should I choose if I work with pool or panel data?Hello! I have a longitudinal dataset, which contains observations of individuals between 2008-2017.…
Computing IPW estimator by handHello everyone, For my project, I try to know if a certain type of policy ("pol", which is a dummy)…
Combining a newly constructed dummy variables to one categorical variable for analysis/refcatDear Statalist, I have currently created four variables about family status: 1) Parents living toge…
Margins for Interaction TermI have run the following regression and am trying to analyse whether the initial level of Income of …
Difference between quietly gen, quietly test and quietly regress?Hi guys, I'm trying to replicate a paper but could not understand the meaning of the following comma…
Subscribe to:
Post Comments (Atom)
0 Response to Generate New Variable Only For Certain Data
Post a Comment