BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Dave25
Quartz | Level 8

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;

1 ACCEPTED SOLUTION

Accepted Solutions
Jay54
Meteorite | Level 14

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/

 

View solution in original post

4 REPLIES 4
Jay54
Meteorite | Level 14

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.

GroupLabel.png

Dave25
Quartz | Level 8
Thanks! - any way I can get the year value on the left side of the axis line? (tried a number of options, with no luck)
Jay54
Meteorite | Level 14

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/

 

Dave25
Quartz | Level 8
thanks - lots of good ideas! I haven't been able to get sgpanel to work, but your solution provided what I needed (I can use "ods layout gridded columns=2" to get where I want to go)

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1417 views
  • 1 like
  • 2 in conversation