When generating a new variable (for example categorizing a continuous variable), it automatically assigns a group to missing data from the first. For example, when I say gen newvar [= 1 if oldvar >=10], it automatically assigns a "1" for missing data from the old var. Is there a way to keep the new data as missing when there is no data point from which to assign the new value?
Yes,
gen newvar = 1 if oldvar >=10 & oldvar !=.
replace newvar = . if oldvar==.