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
PS matching, teffectsHello people, I'm trying to evaluate the impact of remittances on expenditure using propensity score…
Binary instrumental variableI am using instrumental variable estimation, and my instrument is a binary variable (1=yes, 0=no). M…
quaids standard errorsHi, I am estimating an Almost Ideal Demand System (AIDS) for different meat types using the stata co…
How to write an egen function that takes one variable as an input, but produces two variables using the input variable as a stub?Good afternoon, I am trying to write an egen function that takes one newvar as an input, but genera…
How to increase standard deviation by 1?Holding other variables constant, how do you know how much you need to increase 1 independent variab…
Subscribe to:
Post Comments (Atom)
0 Response to Create new variable based small value among two existing variables
Post a Comment