Hi , I am trying to recreate the following graph with my own data:
Just an example so you can get an idea of data:
country | ownsaphone | year |
Benin | no | 2016 |
Benin | yes | 2021 |
Benin | no | 2021 |
Benin | yes | 2016 |
Botswana | no | 2016 |
Botswana | yes | 2016 |
Botswana | no | 2021 |
Botswana | yes | 2021 |
Burkina faso | no | 2016 |
Burkina faso | yes | 2016 |
Burkina faso | no | 2021 |
Burkina faso | yes | 2021 |
Cameroon | no | 2016 |
Cameroon | yes | 2016 |
Cameroon | no | 2021 |
Cameroon | yes | 2021 |
Conte d Ivoire | no | 2016 |
Conte d Ivoire | yes | 2016 |
Conte d Ivoire | no | 2021 |
Conte d Ivoire | yes | 2021 |
Gabon | no | 2016 |
Gabon | yes | 2016 |
Gabon | no | 2021 |
Gabon | yes | 2021 |
Ghana | no | 2016 |
Ghana | yes | 2016 |
Ghana | no | 2021 |
Ghana | yes | 2021 |
graph bar (percent) ownsaphone if ownsaphone == 1, over(year) over (country) asyvars blabel (bar, format(%9.1f))
Obviously, this was not the result that I wanted . I need the bars to show the percentage of people that do own a phone. For example, for Benin in 2021 the bar should show that 77.58% of people owns a phone. I now know that I have to pre-calculate the percentage before. However, I am having trouble with this. Any help would be appreciated - thanks.
Comment