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
how to do a maximum simulated likelihood estimation?Dear statlist: I want to do a MSLE for the following equation systems: the choice function: Dit = 1 …
How to Create Pie ChartHi, I want to create a pie chart in the same way like in the link below https://imaa-institute.org/…
Pie ChartHi, I want to create a pie chart in the same way like in the link below https://imaa-institute.org/…
Not able to convert string to date using date()Hi, I am having trouble converting a string to a date. I have imported an excel file, and have a v…
Testing overidentification with categorical covariatesHi everyone, I am using Stata Version 14.2 and currently run a 2SLS Regression using the ivprobit c…
Subscribe to:
Post Comments (Atom)
0 Response to Create new variable based small value among two existing variables
Post a Comment