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?
Unable to refer to sreturned varlist outside of programI wrote an sclass program which returns two variable lists in separate macros: Code: capture prog…
Recode returns incorrect codeI am try to execute the following code Code: recode educn (1=0)(2/4=1)(5=3)(6=5)(12=15)(10=12)(8=1…
String variable to date formatHi, I am encountered with a problem in converting a string variable to date format to enable time s…
Any alternative to svy: bsqreg ? [Since svy does not support bsqreg]I was wondering if there are any alternatives to using svyset since bsqreg does not support svy and …
Loop Through The Same Procedures with Multiple DatasetsHi all, I have several datasets that I would like to do the same procedures to. I have the same gen…
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