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
generate dummy variable with two if conditionsHello everyone, i have a data set with the two dummy variables date4 and knowledgedum. I want to cr…
Fuzzy match and group names within a listHi there! I have a long list of mutual fund names ever appeared in CRSP. I want to fuzzy match and g…
Creating graphs showing survival curves with confidence intervals on multiple record dataHi Statalist. Is there a way to show survival curves with confidence intervals for multiple-record …
Which model I should use?I have cross-sectional data from a contingent valuation survey. I need to make a dependent variable …
Testing correlation of two variables with many variablesHi I have the following variables drought_rp, flood_rp, *_rms *_rms represents 50 variables with _rm…
Subscribe to:
Post Comments (Atom)
0 Response to Generate New Variable Only For Certain Data
Post a Comment