I have a data set in which several observations have missing values, denoted by . (system missing).
For the observations that actually do have values, I want to make a dummy variable with the value 1 if the observations have a value; otherwise the dummy variable stays missing (I used gen dummy = .).
When I type replace dummy = 1 if variable > 0 it does indeed replace the dummy with 1, but for some reason it does for every observation, also those with a missing value.
How do I only replace it for the values which have a non-missing value?
economicswould not mean, say, that a question purely about economics was on-topic here. https://stats.stackexchange.com/help/on-topic explains. – Nick Cox Nov 29 '19 at 10:15