Yes.
bysort rs1010: gen freq = _N
egen group = group(freq rs1010)
replace group = group - 1
labmask group, values(rs1010)
-search labmask- for locations.
Nick
[email protected]
Bhoom Suktitipat
Is there a possible way to automatically code a categorical variable
based on its frequency?
For example,
my variable contains ( a string variable)
. tab rs1010
rs1010 | Freq. Percent Cum.
------------+-----------------------------------
1/1 | 353 64.77 64.77
1/3 | 163 29.91 94.68
3/3 | 29 5.32 100.00
------------+-----------------------------------
Total | 545 100.00
If I use decode rs1010, gen(newrs) I got 1/1 as 0 instead.
Basically, I want to encode 3/3 (lowest frequency category) as 0, 1/3
as 1, and 1/1 as 2.
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/