- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi everyone,
I would like to create a vertical bar chart that looks like this:
In the chart, I would like to group 2 variables (Sex and Category) but the "Group" option in the Vbar statement only accepts 1 variable. I have tried to use sgpanel but I need 2 columns close together and I think I will use another variable (like age group) in the "panelby" statement to make comparison
The final chart should be like this (an example from an article)
Could you any idea to create this chart
Many thanks in advance
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Building on @Ksharp's example, would this kind of display work for you?
ods html file="gridded.html";
ods layout gridded advance=bygroup rowgutter=0;
ods region;
ods graphics / width=100% height=150px;
proc sgpanel data=sashelp.heart noautolegend;
by chol_status;
panelby status/layout=columnlattice onepanel novarname HEADERBACKCOLOR=white noborder
NOHEADERBORDER COLHEADERPOS=bottom;
vbar sex/group=bp_status BARWIDTH=0.95;
colaxis display=(nolabel) offsetmin=0.4 offsetmax=0.4;
run;
ods layout end;
ods html close;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
proc sgpanel data=sashelp.heart noautolegend;
panelby status/layout=columnlattice onepanel novarname HEADERBACKCOLOR=white noborder
NOHEADERBORDER COLHEADERPOS=bottom;
vbar sex/group=bp_status BARWIDTH=0.95;
colaxis display=(nolabel) offsetmin=0.4 offsetmax=0.4;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the code
But I think this only solves half of my problem. After that code, I could not find out how to add another variable into the chart
Let me take an example of the chart from an article. I think that would be complex but I need to add 3 grouping variables into my chart.
Could we do it on SAS ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Building on @Ksharp's example, would this kind of display work for you?
ods html file="gridded.html";
ods layout gridded advance=bygroup rowgutter=0;
ods region;
ods graphics / width=100% height=150px;
proc sgpanel data=sashelp.heart noautolegend;
by chol_status;
panelby status/layout=columnlattice onepanel novarname HEADERBACKCOLOR=white noborder
NOHEADERBORDER COLHEADERPOS=bottom;
vbar sex/group=bp_status BARWIDTH=0.95;
colaxis display=(nolabel) offsetmin=0.4 offsetmax=0.4;
run;
ods layout end;
ods html close;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Your idea guide me a lot to modify my code
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
proc sgpanel data=sashelp.heart noautolegend;
panelby Smoking_Status bp_status/layout=lattice onepanel novarname HEADERBACKCOLOR=white noborder
NOHEADERBORDER COLHEADERPOS=bottom;
vbar sex/group=Weight_Status BARWIDTH=0.9;
colaxis display=(nolabel) offsetmin=0.4 offsetmax=0.4;
run;