Hello everyone,
I want to create bins from a age variable (which contains values from 15 up to 64). Any idea how can I do that correctly? I need to do a binscatter plot by age levels afterwards.
My idea was to do the following:
but when I sum by 8 values, I don't obtain the sum that I would rather obtain. Here is a dataex sample:
Thanks a lot in advance for the help.
Best,
Michael
I want to create bins from a age variable (which contains values from 15 up to 64). Any idea how can I do that correctly? I need to do a binscatter plot by age levels afterwards.
My idea was to do the following:
Code:
egen age_bins = cut(ca_age), group(8)
Code:
* Example generated by -dataex-. For more info, type help dataex clear input int ca_age float age_bins 37 2 40 3 30 1 33 1 34 2 54 5 37 2 62 7 56 6 39 2 50 4 47 4 49 4 45 3 58 6 60 7 52 5 17 0 46 4 47 4 64 7 34 2 53 5 50 4 52 5 53 5 53 5 29 1 59 6 31 1 39 2 34 2 40 3 48 4 55 6 29 1 24 0 35 2 59 6 20 0 40 3 52 5 44 3 58 6 61 7 32 1 31 1 52 5 51 5 35 2 end label values ca_age ca_age
Best,
Michael
Comment