Data visualization with SAS programming

sgpanel - showing group on axis #2 (ordering & split)

Accepted Solution Solved
Reply
Contributor
Posts: 27
Accepted Solution

sgpanel - showing group on axis #2 (ordering & split)

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;


Accepted Solutions
Solution
‎04-10-2016 12:00 PM
SAS Super FREQ
Posts: 1,141

Re: sgpanel - showing group on axis #2 (ordering & split)

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


All Replies
SAS Super FREQ
Posts: 1,141

Re: sgpanel - showing group on axis #2 (ordering & split)

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.

Contributor
Posts: 27

Re: sgpanel - showing group on axis #2 (ordering & split)

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!

Solution
‎04-10-2016 12:00 PM
SAS Super FREQ
Posts: 1,141

Re: sgpanel - showing group on axis #2 (ordering & split)

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

Contributor
Posts: 27

Re: sgpanel - showing group on axis #2 (ordering & split)

perfect! thank you
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 416 views
  • 0 likes
  • 2 in conversation