Typical Use:
egen bigvar = rmax(varx vary varz)
. egen ea_tag = tag(ea_code);
. tab district if ea_tag == 1;
district | Freq. Percent Cum.
-------------------+-----------------------------------
Kailahun | 22 10.00 10.00
Kenema | 28 12.73 22.73
Kono | 13 5.91 28.64
Bombali | 16 7.27 35.91
Kambia | 9 4.09 40.00
Koinadugu | 12 5.45 45.45
Port Loko | 16 7.27 52.73
Tonkolili | 12 5.45 58.18
Bo | 22 10.00 68.18
Bonthe | 4 1.82 70.00
Moyamba | 11 5.00 75.00
Pujehun | 8 3.64 78.64
Western Area Rural | 12 5.45 84.09
Western Area Urban | 35 15.91 100.00
-------------------+-----------------------------------
Total | 220 100.00
| diff(varlist) | equals 1 for observations where the variables are not all equal, 0 if they are |
| eqany(varlist), v(numlist) | equals 1 for observations where any of the variables in varlist are equal to any of the values in numlist. |
| neqany(varlist), v(numlist) | equals number of variables in varlist equal to any of the values in numlist. |
| rank(exp) | gives the rank of the observation based on exp where the highest value corresponds to 1. Equal observations are assigned the average rank. |
| rmax(varlist) rmin(varlist) rmean(varlist) |
equals the maximum (minimum, mean) of the variables in varlist |
| robs(varlist) | for each observation, equals the number of variables among varlist that aren't missing. |
| tag(varlist) | equals 1 for 1 observation of each distinct group defined by varlist |
. gen num_goods_1 = own_radio + own_bicycle + own_TV + own_fan; (5 missing values generated) . egen num_goods_2 = rsum(own*); . egen num_goods_3 = neqany(own*), v(1);As Stata notes, the first way results in a missing value if any of the component variables are missing. The second two count a missing as a 0.
contact: djiboliz@gmail.com
last modified: 23 Nov 2007