Hello and thank you!
I am trying to generate a new variable that is the variable with the max value among a list of 8 variables. When I use the egen command with a rowmax function is it possible to list which variable within my list is variable for the max value? I'ld like to create this new variable across observations.
For example,
id v1 v2 v3 v3 v4 v5
1 0 2 1 9 7 8
2 1 1 2 3 4 6
3 9 8 7 6 5 4
For this new variable I would like it to generate it as such:
id max_v
1 v3
2 v5
3 v1
My current problem is that the roxmax is returning just the numeric maximum for each observation rather than which variable within my list of variables is the maximum. Any and all help would be amazing.
Related Posts with Generating a new variable that is the variable with the max value from rowmax
year fixed effects in a difference in differences modelHello everyone, this is my first post here and I hope to do everything well to have some help about …
skip lines of code in do fileHi, Is there any way to skip some lines of codes in a do file? As an example, I want to run codes fr…
Strange behavior of Stata with Classes and Python interactionDear All, I have encountered a rather strange behavior of Stata: Array Basically after obtaining …
Ignoring multiple characters while using destringIf I want to have Stata ignore all letters that come after L while using destring, is there a way to…
Randomizing years and statesHi , I have a variable of interest which is an indicator variable (LAW) that equals 1 if a firm is …
Subscribe to:
Post Comments (Atom)
0 Response to Generating a new variable that is the variable with the max value from rowmax
Post a Comment