I am creating a bar chart where I display 30 individual charts using the "by statement":
proc gchart data = analytic_file;
by group_id;
vbar age_category / type=percent;
run;
The above creates 30 individual charts (for each group) showing the age category percentages for each group_id (great!)
On each of the 30 charts, I want to show side by side 1) the age_category precentages for the group AND 2) the overall percentages for the entire population (analytic_file, not grouped by groupid). Ex. There are 30% who are 18-25 in groupd A, and 45% who are 18-25 for the entire population.
How would I do this?
I figure it out. I am using proc freq to come up with percentages for each of the groups individually:
http://blogs.sas.com/content/iml/2012/12/03/show-percentages-for-bar-charts-with-proc-sgplot.html
Then I am merging the output of the two datasets for two new variables: one for the percent overall, and one for the percent for the group.
Well, advice one - move to sgplot/graph template language. With this you can overlay as much as you want. You can find examples for almost any type of graph here:
http://blogs.sas.com/content/graphicallyspeaking/
If you can't find what you want there then post some test data (datastep), and what the output should look like.
proc sgplot was defintely the way to go, and solved a couple of my other problems.
However, I still have the same questions. I want to overlay (or side by side) each of these 35 graphs generated with the by statement:
A)
proc sgplot data= analytic_cohort;
by pat_groupid;
vbar agecat_clinical;
run;
With the one graph generated by:
B)
proc sgplot data= analytic_cohort;
vbar agecat_clinical;
run;
B) contains the overall agecat_clinical for the entire population and I want that next to the age_cat clinical for the pat_groupid.
I figure it out. I am using proc freq to come up with percentages for each of the groups individually:
http://blogs.sas.com/content/iml/2012/12/03/show-percentages-for-bar-charts-with-proc-sgplot.html
Then I am merging the output of the two datasets for two new variables: one for the percent overall, and one for the percent for the group.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.