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?
How to convert numeric date variable?Current format for date is %td and numeric The date is shown as 04feb2017 and I want to change it t…
Parallel trend assumption in Diff and Diff methodHi, Currently, I am working with CPS monthly microdata from https://ceprdata.org/cps-uniform-dat.../…
How margins handles the atmeans optionAsking my students to use the margins command after mlogit for computing marginal effects (using dyd…
egen mean_var = mean(var), by(xx & xx)Hi How do I generate a mean variable sorted by both year and origin? I want to generate the mean v…
Predict after xtlogitI am using xtlogit with fe options. I notice that the results drop some observations due to all posi…
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