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

Thought I had it, but ran into two problems I can't seem to solve:

1) why won't the year (group) sort as coded in the hbarparm line, "GROUPORDER= ascending"

2) how do I get the value of q (category) to "split"?

 


data a; input q $ year pct;
cards;
4yr,Coll 2013 0.44
2yr,Coll 2013 0.43
4yr,Coll 2014 0.29
2yr,Coll 2014 0.63
;
run;
proc sgplot data=a noautolegend;
hbarparm category=q response=pct / group=year groupdisplay=cluster GROUPORDER= ascending ;
yaxistable q / location=inside position=left
valuejustify=right label = ' ' ;
yaxistable year/ class=year classdisplay=cluster location=inside position=left
valuejustify=right valueattrs=(size=6) label = ' ' ;
xaxis display=(noline noticks nolabel) grid;
yaxis display=none FITPOLICY= SPLITALWAYS SPLITCHAR="," ;
run;

1 ACCEPTED SOLUTION

Accepted Solutions
Jay54
Meteorite | Level 14

Tick value splitting is supported on the YAXIS, but not in the YAXISTABLE.  For the table, the width of the table is computed based on the width of the string.  I do not see any related options in the YAXISTABLE statement.

 

To get the look you are going for, I suggest keeping the Y axis for the "q" values and using Axistable only for the Year.

 

proc sgplot data=a noautolegend noborder;
hbarparm category=q response=pct / group=year groupdisplay=cluster GROUPORDER= ascending ;
/*yaxistable q / location=inside position=left*/
/*valuejustify=right label = ' ' ; */
yaxistable year/ class=year classdisplay=cluster location=inside position=left
valuejustify=right valueattrs=(size=6) label = ' ' ;
xaxis display=(noline noticks nolabel) grid;
yaxis display=(noline nolabel notick) FITPOLICY= SPLITALWAYS SPLITCHAR="," ;
run;

 

GroupLabel_2.png

View solution in original post

4 REPLIES 4
Jay54
Meteorite | Level 14

Remember, now you are using the YAXISTABLE to provide the labels.  So, you need to put the same GROUPORDER and CLASSORDER for the HBARPARM and the YAXISTABLE.

 

proc sgplot data=a noautolegend;
hbarparm category=q response=pct / group=year groupdisplay=cluster GROUPORDER=reversedata ;
yaxistable q / location=inside position=left
valuejustify=right label = ' ';
yaxistable year/ class=year classdisplay=cluster location=inside position=left
valuejustify=right valueattrs=(size=6) label = ' ' classORDER=reversedata;
xaxis display=(noline noticks nolabel) grid;
yaxis display=none FITPOLICY= SPLITALWAYS SPLITCHAR=",";
run;

 

For splitting the strings for "q", I'll have to look at the syntax for YAXISTABLE.  I will check and get back.

Dave25
Quartz | Level 8

Thanks again for your help.

1) I initially thought that I might need to specify order in the YAXISTABLE Statement, but I bit on what I saw in the on-line documentation:

 

CLASSORDER=DATA | REVERSEDATA | ASCENDING | DESCENDING

specifies the order in which the class values are displayed.

Restriction

This option is ignored when the axis table is used with DOT, HBAR, VBAR, HLINE, and VLINE statements. If the GROUPORDER= option is specified in the chart, then that group order variable is used as the class order variable for all axis tables.

 

-- and, still can't see why REVERSEDATA will work, but ASCENDING won't.

 

2) Also thought that the split needed to be handled in the YAXISTABLE Statement, but have been unable to find anything related to this in the Documentation.  Look forward to any suggestions you may have!

Jay54
Meteorite | Level 14

Tick value splitting is supported on the YAXIS, but not in the YAXISTABLE.  For the table, the width of the table is computed based on the width of the string.  I do not see any related options in the YAXISTABLE statement.

 

To get the look you are going for, I suggest keeping the Y axis for the "q" values and using Axistable only for the Year.

 

proc sgplot data=a noautolegend noborder;
hbarparm category=q response=pct / group=year groupdisplay=cluster GROUPORDER= ascending ;
/*yaxistable q / location=inside position=left*/
/*valuejustify=right label = ' ' ; */
yaxistable year/ class=year classdisplay=cluster location=inside position=left
valuejustify=right valueattrs=(size=6) label = ' ' ;
xaxis display=(noline noticks nolabel) grid;
yaxis display=(noline nolabel notick) FITPOLICY= SPLITALWAYS SPLITCHAR="," ;
run;

 

GroupLabel_2.png

Dave25
Quartz | Level 8
perfect! thank you

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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
  • 1152 views
  • 0 likes
  • 2 in conversation