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
endogenous switching regression modelHello, Please I am new in stata so it's quite difficult for me to solve some regression problems. A…
ci for categorial variables - tabci?I'm just wondering why Stata gives CIs for binary variables - ci proportions varname - but, as far a…
Replace if not found within a loopDear all, I am trying to bottom and top coding the household income for each country - wave. I am us…
-dstdize- to calculate average age-adjusted death rate by raceGood Morning, I would like to calculate the average age-adjusted death rate by race (separately for…
Command stir does not accept iweightsHello I've been using the command stir (incidence rate comparison). The manual says that stir allows…
Subscribe to:
Post Comments (Atom)
0 Response to Create new variable based small value among two existing variables
Post a Comment