Hello,
I would like to generate new variable by choosing a small value between two existing variables. For example, given that there exists two variables, A and B, I would like to generate new variable C by selecting smaller values between A and B.
Year A B C
1990 1 3 1
1991 2 -1 -1
1992 0 2 0
1993 -1 -3 -3
I tried to search "if else" command using "gen" command, but I could not find a proper solution to solve this problem.
Due to different signs of each value, subtracting or summing does not help to discern which value is larger or smaller.
Any advice and tip would be helpful!
Thank you
Related Posts with Create new variable based small value among two existing variables
Stata 17 ptrendsHi, I'm a student working on a diff in diff using Stata 17's new didregress. I used the postestimati…
replicating an instrumented model in eregress and ivreg2 (or ivregress)Hi Stata people, I would like to replicate a model I am using in eregress (Stata 15 and up) and ivr…
Replace values in each rowHi, In the following dataset: Code: * Example generated by -dataex-. To install: ssc install data…
Mean-adjusted change research designDear all, For my Master Thesis I am examining the change in institutional holdings after receiving …
replicating an instrumented model in eregress and ivreg2 (or ivregress)Hi Stata people, I would like to replicate a model I am using in eregress (Stata 15 and up) with iv…
Subscribe to:
Post Comments (Atom)
0 Response to Create new variable based small value among two existing variables
Post a Comment