My apologies if this has been asked before, I'm just sure how to explain it, so I'm showing the table I need to make.
With the current data I can make a table like this:
Age | |||||||||
Country code | 15-19 | 20-24 | 25-29 | 30-34 | 35-39 | 40-44 | 45-49 | Total | |
Angola | 20.44 | 15.40 | 11.35 | 10.30 | 10.68 | 12.52 | 10.92 | 12.55 | |
Burkina-Faso | 10.12 | 13.88 | 12.49 | 13.73 | 13.09 | 14.31 | 14.80 | 13.18 | |
Benin | 7.01 | 9.71 | 12.83 | 13.91 | 11.90 | 10.94 | 12.18 | 11.74 | |
Burundi | 3.76 | 9.22 | 11.45 | 13.69 | 13.65 | 14.31 | 15.27 | 11.56 | |
DR Congo | 16.92 | 15.90 | 16.99 | 15.57 | 16.91 | 16.97 | 14.99 | 16.39 | |
Congo | 12.95 | 8.21 | 7.64 | 7.18 | 8.87 | 7.97 | 7.38 | 8.17 | |
Cote d'Ivoire | 7.84 | 7.26 | 6.78 | 6.56 | 6.20 | 6.51 | 7.28 | 6.81 | |
Cameroon | 14.89 | 11.93 | 10.49 | 9.20 | 8.26 | 8.25 | 7.80 | 10.28 | |
Ethiopia | 6.08 | 8.49 | 9.97 | 9.86 | 10.43 | 8.21 | 9.38 | 9.32 | |
Total | 100.00 | 100.00 | 100.00 | 100.00 | 100.00 | 100.00 | 100.00 | 100.00 |
. | |||||||||
Age | |||||||||
Country code | 15-19 | 20-24 | 25-29 | 30-34 | 35-39 | 40-44 | 45-49 | Total | |
Angola | 20.44 | 15.40 | 11.35 | 10.30 | 10.68 | 12.52 | 10.92 | 12.55 | |
Burkina-Faso | 10.12 | 13.88 | 12.49 | 13.73 | 13.09 | 14.31 | 14.80 | 13.18 | |
Benin | 7.01 | 9.71 | 12.83 | 13.91 | 11.90 | 10.94 | 12.18 | 11.74 | |
Burundi | 3.76 | 9.22 | 11.45 | 13.69 | 13.65 | 14.31 | 15.27 | 11.56 | |
DR Congo | 16.92 | 15.90 | 16.99 | 15.57 | 16.91 | 16.97 | 14.99 | 16.39 | |
Congo | 12.95 | 8.21 | 7.64 | 7.18 | 8.87 | 7.97 | 7.38 | 8.17 | |
Cote d'Ivoire | 7.84 | 7.26 | 6.78 | 6.56 | 6.20 | 6.51 | 7.28 | 6.81 | |
Cameroon | 14.89 | 11.93 | 10.49 | 9.20 | 8.26 | 8.25 | 7.80 | 10.28 | |
Ethiopia | 6.08 | 8.49 | 9.97 | 9.86 | 10.43 | 8.21 | 9.38 | 9.32 | |
Africa average |
In short, the country variable has 9 categories, and I want to add anothor which willl be the average of the rest.
Thank you in advance.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input byte(Age Country) float id 5 1 1 6 1 2 6 1 3 3 1 4 3 1 5 3 1 6 7 1 7 1 1 8 4 1 9 4 1 10 6 1 11 3 1 12 3 1 13 3 1 14 2 1 15 3 1 16 3 1 17 4 1 18 4 1 19 3 1 20 2 1 21 4 1 22 4 1 23 3 1 24 1 1 25 6 1 26 2 1 27 2 1 28 4 1 29 6 1 30 2 1 31 4 1 32 6 1 33 3 1 34 1 1 35 2 1 36 2 1 37 3 1 38 3 1 39 3 1 40 4 1 41 4 1 42 1 1 43 5 1 44 1 1 45 5 1 46 2 1 47 1 1 48 2 1 49 2 1 50 3 1 51 3 1 52 4 1 53 4 1 54 3 1 55 6 1 56 4 1 57 3 1 58 3 1 59 2 1 60 3 1 61 3 1 62 3 1 63 3 1 64 5 1 65 2 1 66 2 1 67 2 1 68 3 1 69 5 1 70 5 1 71 4 1 72 2 1 73 5 1 74 3 1 75 7 1 76 5 1 77 3 1 78 4 1 79 2 1 80 1 1 81 3 1 82 3 1 83 1 1 84 4 1 85 4 1 86 4 1 87 7 1 88 3 1 89 3 1 90 2 1 91 2 1 92 2 1 93 2 1 94 6 1 95 6 1 96 2 1 97 6 1 98 2 1 99 2 1 100 end label values Age V013 label def V013 1 "15-19", modify label def V013 2 "20-24", modify label def V013 3 "25-29", modify label def V013 4 "30-34", modify label def V013 5 "35-39", modify label def V013 6 "40-44", modify label def V013 7 "45-49", modify
0 Response to Adding the average of a variable as a new category
Post a Comment