Dear Statalist, happy new year!
I want egen to create 5 class of incomes for each country in my dataset.
I tried with this, but it doesn't work:
it says egen ... cut() may not be combined with by (sigh...)
Is there a fast way to do this?
ok
I want egen to create 5 class of incomes for each country in my dataset.
I tried with this, but it doesn't work:
Code:
bysort country: egen income_class = cut(income), group(5)
Is there a fast way to do this?
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input double(s4 s7) 1 8000 1 65000 1 2500 1 60000 1 60000 1 80000 1 56000 1 45000 1 55000 1 80000 1 42000 1 90000 1 70000 1 60000 1 140000 1 53000 1 20000 1 30000 1 8000 1 10000 1 15000 1 50000 1 130000 1 24000 1 40000 1 60000 1 100000 1 120000 1 70000 1 100000 1 40000 1 15000 1 70000 1 4300 1 100000 1 120000 1 60000 1 120000 1 38000 1 35000 1 130000 1 35000 1 30000 1 100000 1 140000 1 70000 1 50000 1 55000 1 65000 1 96000 1 30000 1 49000 1 28000 1 80000 1 40000 1 75000 1 30000 1 100000 1 13000 1 48000 1 56700 1 30000 1 3800 1 30000 1 52000 1 40000 1 75000 1 54000 1 3500 1 55000 1 70600 1 75000 1 70000 1 50000 1 40000 1 70000 2 90000 2 15000 2 11000 2 43000 2 80000 2 38000 2 1000000 2 40000 2 48000 2 28000 2 110000 2 70000 2 50000 2 120000 2 60000 2 36000 2 16000 2 16000 2 70000 2 5000 2 45000 2 48000 2 80000 2 125000 end label values s4 s4 label def s4 1 "Austria", modify label def s4 2 "Fantasyland", modify
Comment