any suggestions on how I can get the group variable on the axis?
(like was available with gchart, using group = and subgroup 😃
Sample code - I'd like the year field to show on the column axis (along with the q field)
data a; input q $ year id $ pct;
cards;
4yr 2013 d 0.44
2yr 2013 d 0.43
4yr 2014 d 0.29
2yr 2014 d 0.63
4yr 2013 i 0.58
2yr 2013 i 0.31
4yr 2014 i 0.54
2yr 2014 i 0.34
;
run;
proc sgpanel data=a noautolegend;
panelby id/columns=2 rows=1;
hbar q / response=pct group =year GROUPDISPLAY=CLUSTER;
run;
Here are some additional ideas. Should work with SGPANEL, but did nto verify.
http://blogs.sas.com/content/graphicallyspeaking/2016/04/08/displaying-group-values-on-axis/
Since you have explicitly turned off the AUTOLEGEND, you can overlay the group value on the bar. If you have SAS 9.4, you can use the TEXT plot. Else, you can use the SCATTER with MARKERCHAR. But to overlay on a bar, you have to use HBARPARM, which is OK since you are not expecting the bar char to summarize data. If you do, you will have to presummarize your data using PROC MEANS, then use HBARPARM.
Note addition of the variable XLBL=0.
data a;
input q $ year id $ pct;
xlbl=0;
cards;
4yr 2013 d 0.44
2yr 2013 d 0.43
4yr 2014 d 0.29
2yr 2014 d 0.63
4yr 2013 i 0.58
2yr 2013 i 0.31
4yr 2014 i 0.54
2yr 2014 i 0.34
;
run;
proc sgpanel data=a noautolegend;
panelby id/columns=2 rows=1;
hbarparm category=q response=pct / group =year GROUPDISPLAY=CLUSTER;
text x=xlbl y=q text=year / group=year groupdisplay=cluster position=right textattrs=(color=black);
colaxis offsetmin=0;
run;
You can creatively put the value anywhere, even rotate it vertically at the base of the bar.
Here are some additional ideas. Should work with SGPANEL, but did nto verify.
http://blogs.sas.com/content/graphicallyspeaking/2016/04/08/displaying-group-values-on-axis/
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.