I need to create a clustered stacked bar graph showing the percentage of unemployed people who got a job across age groups, gender and sectors (all in one graph). I haven't looked at how to cluster them yet as I am having problems with the stacked part at the moment I have created the graph in excel (please see below), but I have been asked to do it in Stata.
What I want, but in Stata:

I have 164, 721 observations in total. Total men = 83,498 and total women = 81,223.
I have divided the data into 3 age groups:
age_group1 = < 30
age_group2 = 30 - 44
age_group3 = > 45
I have 10 sectors that fall under the variable "Activity".
For each sector, I want the following percentages stacked on top of each other:
sector 1: (men_in_age_group1)/ Total_men x 100 , (men_in_age_group2)/ Total_men x 100 , (men_in_age_group3)/Total_men x 100
where "men_in_age_group1" is the number of men in that age group in that sector and "Total_men" is the total number of men in the data set = 83,498.
Then the same for women for sector 1, clustered with the bar above.
The problem is that Stata's stacked bar graphs add up to 100% within each category (in this case each sector). I created three variables:
gen men_age1=1 if sex==1 & age==1
replace men_age1=0 if sex==1 & age > 1
gen men_age2=1 if sex==1 & age==2
replace men_age2=0 if sex==1 & age!= 2
gen men_age3=1 if sex==1 & age==3
replace men_age3=0 if sex==1 & age!= 3
I tried the following graph command:
graph bar men_age1 men_age2 men_age3, over(Activity) stack
but, the percentages it is graphing are:
sector1: (men_in_age_group1)/ Total_men_in_sector1 , (men_in_age_group2)/Total_men_in_sector1, (men_in_age_group3)/Total_men_in_sector1
or:

The problem is the denominator. I have tried searching for help online, but haven't been able to find anything, so far.
I am using Stata 13. Also, this is my first post, so please let me know if there's anything else I should add or if anything is unclear.
Thank you!!
What I want, but in Stata:
I have 164, 721 observations in total. Total men = 83,498 and total women = 81,223.
I have divided the data into 3 age groups:
age_group1 = < 30
age_group2 = 30 - 44
age_group3 = > 45
I have 10 sectors that fall under the variable "Activity".
For each sector, I want the following percentages stacked on top of each other:
sector 1: (men_in_age_group1)/ Total_men x 100 , (men_in_age_group2)/ Total_men x 100 , (men_in_age_group3)/Total_men x 100
where "men_in_age_group1" is the number of men in that age group in that sector and "Total_men" is the total number of men in the data set = 83,498.
Then the same for women for sector 1, clustered with the bar above.
The problem is that Stata's stacked bar graphs add up to 100% within each category (in this case each sector). I created three variables:
gen men_age1=1 if sex==1 & age==1
replace men_age1=0 if sex==1 & age > 1
gen men_age2=1 if sex==1 & age==2
replace men_age2=0 if sex==1 & age!= 2
gen men_age3=1 if sex==1 & age==3
replace men_age3=0 if sex==1 & age!= 3
I tried the following graph command:
graph bar men_age1 men_age2 men_age3, over(Activity) stack
but, the percentages it is graphing are:
sector1: (men_in_age_group1)/ Total_men_in_sector1 , (men_in_age_group2)/Total_men_in_sector1, (men_in_age_group3)/Total_men_in_sector1
or:
The problem is the denominator. I have tried searching for help online, but haven't been able to find anything, so far.
I am using Stata 13. Also, this is my first post, so please let me know if there's anything else I should add or if anything is unclear.
Thank you!!
Comment