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!