I would like to create a new variable which takes the minimum value in each row, (ignoring the zeros). How do you do this?
I tried this below and it didnt work
foreach var of varlist ethos_1rough ethos_2emerg ethos_3temp ethos_5immigrant {
egen higher_ethos = rowmin(`var') if `var' ~=0
}
* Example generated by -dataex-. To install: ssc install dataex
clear
input float(ethos_1rough ethos_2emerg ethos_3temp ethos_5immigrant)
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 2 3 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 3 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 3 0
0 0 3 0
0 0 3 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
1 0 0 0
1 0 0 0
1 0 0 0
0 0 0 0
end
[/CODE]
Related Posts with rowmin
Formatting date from MM/DD/YYYY.I'm trying to format my date but I keep getting a type mismatch error. My dates are labeled as "MM/D…
How come label changes aren't registered by StataHi I just discovered that changes in labels is not captured by either c(changed) or describe (In the…
Difference of two means significantly different to zeroHey guys, I need your help. So I calculated the mean of 2 groups and then calculated the difference …
Drop observation1==0 if Observation2==1Hello I have tried to figure out how to drop a set of observations if they meet two criteria (one of…
Multiple graphs combined with the over option (and only one legend)Dear all, I would like to know your feedback about the following issue. I need to realize the graph …
Subscribe to:
Post Comments (Atom)
0 Response to rowmin
Post a Comment