input id t1 t2 t3
1 1.5 1.4 1.6
2 1.5 . 1.9
3 . 2.0 1.6
4 . . 2.2
5 1.9 2.1 2
6 1.8 2.0 1.9
7 . . .
end
As suggested above, I want to create a new variable called sign.
If t2>t1, then sign=1; if t2<=t1, then sign=0.
Because t1 and t2 all have missing values, how can I keep missing values in the new variable "sign" in Stata?
I think the rule is as long as there is a missing value in t1 or t2, then the variable "sign" should be missing value.
Thanks for your Stata code!
Related Posts with How to create a new binary variable (0-1) based on some conditions in Stata?
int() and round()I am rounding values of a variable to the closest integer. For some reason, int(x) and round(x) give…
Question about Generalized DIDHi everyone, I have a research project trying to investigate the impact of a policy shock, and the …
Creating an indicator for when different observations in a group have the same value on a variableCould someone please take a look at a line of code and tell me where I am going wrong. Of my 3,000 U…
Displaying thousands with "K" suffixI wish that my data will display shortened numbers, for example: I wish to display the number "1000…
Changing format of ylabels in a schemeHi, I want to add a parameter to a scheme to make the ylabels of a graph display in a given format.…
Subscribe to:
Post Comments (Atom)
0 Response to How to create a new binary variable (0-1) based on some conditions in Stata?
Post a Comment