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?
Transformation of valuesHi, I have a data set on tumors with the variables karnofsky index/KI (categorical with values 40, …
How to loop through two locals instead of all variables inside each local Code: local ipv "angry fear intimacy_idx cont12_idx ev12_idx pv12_idx sv12_idx ipv_ovall_idx" lo…
HeckmanHi, How do I apply weights in Heckman selection model? Thank you …
Latent growth curve modelingDear experts, I am currently trying to fit an unconditional growth curve model (as a first step befo…
keep observations if first 2 character of the string is capital letterI have a dataset where the variable x is a string. I need to keep only observations at which the fir…
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