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)

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

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