I would like to create a categorical variable from several continuous variables. In my dataset, I have 10 variables that identify a type of problem a child experiences (abuse, neglect, etc.). These variables include the number of children that fall into those categories for each region in each year.
I am trying to create instead a categorical variable with 10 categories for each of these problems, that way I can then use the data to start producing some graphs (for e.g. pie charts displaying the percentage for each category in each region for each year).
I am not sure where to begin with my code. Please see an example of my dataset. The variables of interest begin with N, I am only showing 3 of them as dataex needed me to specify fewer variables.
I am trying to create instead a categorical variable with 10 categories for each of these problems, that way I can then use the data to start producing some graphs (for e.g. pie charts displaying the percentage for each category in each region for each year).
I am not sure where to begin with my code. Please see an example of my dataset. The variables of interest begin with N, I am only showing 3 of them as dataex needed me to specify fewer variables.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input int time_period long(reg N1_Abuse_or_neglect N2_Childs_disability_or_illness) int N3_Parents_disability_or_illness 2022 5 13950 2050 230 2022 6 40170 3800 850 2022 11 30690 2140 510 2022 1 15920 2080 1040 2022 10 27350 3470 790 2022 2 18450 3950 550 2022 4 35970 7280 2540 2022 8 29430 5230 1440 2022 9 18900 2170 980 2022 3 13650 2590 1330 2022 7 22330 4690 1210 2021 5 13890 1970 260 2021 6 37700 3750 870 2021 11 29800 2590 480 2021 1 15920 1950 1130 2021 10 25640 3560 790 2021 2 18380 3820 540 2021 4 33940 7320 2790 2021 8 26830 5020 1500 2021 9 17100 2150 1090 2021 3 13390 2720 1480 2021 7 20550 4610 1310 2020 5 13740 2030 230 2020 6 37530 3710 890 2020 11 29600 2500 510 2020 1 15760 1530 970 2020 10 24100 3470 920 2020 2 19080 3750 640 2020 4 33690 7420 2850 2020 8 26800 5310 1410 2020 9 17150 2230 1010 2020 3 13950 2780 1500 2020 7 19740 4640 1350 2019 5 12280 2110 240 2019 6 38360 3900 1050 2019 11 28660 2530 570 2019 1 15980 1820 1090 2019 10 24190 3510 1010 2019 2 19050 3960 640 2019 4 34690 7160 2680 2019 8 23890 5220 1420 2019 9 19190 3390 1190 2019 3 14380 2850 1510 2019 7 20300 4300 1170 2018 5 11240 2220 310 2018 6 36760 3930 1140 2018 11 28180 2600 590 2018 1 15170 1890 980 2018 10 24830 4020 1220 2018 2 19420 3930 720 2018 4 36090 7700 2800 2018 8 24360 5690 1610 2018 9 19220 3250 1130 2018 3 14470 3040 1570 2018 7 21630 4670 1230 end label values reg reg label def reg 1 "East Midlands", modify label def reg 2 "East of England", modify label def reg 3 "Inner London", modify label def reg 4 "London", modify label def reg 5 "North East", modify label def reg 6 "North West", modify label def reg 7 "Outer London", modify label def reg 8 "South East", modify label def reg 9 "South West", modify label def reg 10 "West Midlands", modify label def reg 11 "Yorkshire and The Humber", modify
Comment