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
Error in postestimation testHi, I am doing a regression analysis with cross sectional data and matched pairs design. In order …
Temporal disaggregation with no indicator in Stata?!Hi all Is there any code available in Stata for time series disaggregation with no indicator variab…
Granual calculations in an unbalanced panel data set are not consistent with the aggregatesI have a panel dataset with these variables variable name type format label variable label --------…
Survival analysis (hazard model): how to set up the 10-year data in a three-month windowDear Statalist, I have a set of data (from 2011-2020). I want to test when event X happened for use…
Bug found in nearmrg command (?)Hello everyone, After hours of debugging of my code, I think I found a bug in the command nearmrg t…
Subscribe to:
Post Comments (Atom)
0 Response to rowmin
Post a Comment