Relational operators (>, <. >=, <=, ==, !=) evaluate to 1 if the expression is true and 0 if false. Given this definition, a dummy variable can be created using, for example:
gen newvar = (oldvar <= somethreshold) if !missing(oldvar)
Instead of the longer alternative:
gen newvar = 1 if oldvar <= somethreshold
replace newvar = 0 if oldvar > somethreshold if !missing(oldvar)
Why bother with the if-not-missing statement? If this statement is excluded, i.e.,
gen newvar = (oldvar <= somethreshold)
and oldvar contains observations with missing values, newvar will take the value 0 (because a missing value is treated as a very large number) where oldvar is missing, which may not be your intention. Stay safe!