07-17-2013 06:10 PM
I am still relatively new to SAS and creating graphs/charts using SAS and could use some help determining if it is possible to create a single vertical side-by-side graph with multiple variables. Essentially, I need to subgroup by gender,but I need the groups for age, marital status, and income to appear on the same graph. Is it possible to accomplish this in SAS? Any guidance would be extremely helpful.
07-18-2013 09:48 AM
I believe the example below could help you achive your desired results:
proc sort data=sashelp.heart;
proc freq data=sashelp.heart;
table weight_status / out=temp2;
array change _CHARACTER_;
do over change;
if change="" then change="Unknown";
proc gchart data=sashelp.heart;
vbar weight_status/ group=sex sumvar=count;
The group= option should allow you to achieve your desired result. Thjere are definitely different ways to go about it depending on how much manipulation of your data you want to do before hand versus letting proc gchart do some of it via the statistic options. With multiple variables each having a different scale however, it is probably best to do all calculations beforehand. For instance, I would suggest you run your summary statistics on your table, then use proc transpose to get age/marital_status/income variable vertically within a new variable, use that variable and it's value column as respectively, the hbar variable and the sumvar= variable.
If you wanted sex distinction to pile vertically instead of horizontally, you can do so with the subgroup= option.
07-18-2013 11:41 AM
Thank you for your response Vincent. It was very helpful, and I think I may have this graph figured out now. :smileygrin:
07-18-2013 10:32 AM
From a data visualization perspective you need to be concerned about making a graph too busy or too complicated to understand. You may well be better off to use several smaller simpler graphs on one page that present all of the stories contained in the data.