Here is my data and I want create the new variable in the stata based on the information given in the data. But when I apply the following command, I do not see the correct calculation. (Variable are in numeric format when I do the analysis)
1- New_Var1: should have value of either var2 or var3, whichever is the bigger.
my command " gen New_Var1= var1 if var1>var2"
"replace New_Var1= var2 if var2>=var1"
When I check the results, it does not show the right answer. The below data is just an example, my real data has some missing values. Do I need to put somethings in the command for missing value?
Thanks in advance
clear
input str4(var1 var2 var3)
"var1" "var2" "var3"
"1" "12.4" "10.9"
"2" "9.5" "9.3"
"3" "13.2" "7.6"
"4" "14.5" "9.9"
"5" "12.1" "12.4"
"6" "17.6" "25.0"
"7" "15.4" "12.8"
"8" "7.9" "7.8"
"9" "16.7" "14.5"
"10" "10.6" ""
end
Related Posts with New Variable
Different Regression Results after each rerunHello everbody, excited to make my very first post. I am currently writing my Thesis with Stata. I a…
R-square in logistic regressionHello, For my study, I analyze the data using logistic regression analysis, but when changing the sc…
Collinearity-removed variables, other statistics not showing up.I'm currently running a lot (77) of different time-series regressions, each of which use different f…
Running IV with ordinal instrument on binary endogenous independent variable and continuous outcome variableDear Stata Community, I would like to ask if anyone here could offer some advice on the estimation …
Finding relevant datesHi This is my first attempt at using dataex Code: * Example generated by -dataex-. For more info,…
Subscribe to:
Post Comments (Atom)
0 Response to New Variable
Post a Comment