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;
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;
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.
Thanks again for your help.
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!
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;
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 16. 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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: