BookmarkSubscribeRSS Feed
Manj
Fluorite | Level 6

Hi ,

  I have this code to create the graph attached.

proc sgpanel data=&G_DDDATASETNAME pctlevel=group ;
panelby trt01p / layout=columnlattice onepanel novarname colheaderpos=bottom headerattrs=(Size=8) ;
vbar avisit / group=avalc stat=percent grouporder=ascending attrid=avalc;
styleattrs datacolors=(white lightgrey darkgrey grey black) datacontrastcolours=( black black black black black);
colaxis display=(nolabel) valueattrs=(size=8);
rowaxis label='Percentage of Patients' ;
keylegend /title='PGI-S response categories:' valueattrs=(size=8);
colaxistable avalx / class=avalx classdisplay=stack stat=freq labelpos=right classorder=ascending labelattrs=(size=8) valueattrs=(size=8);
run;

 

 

Manj_0-1589196986066.png

I would like the xaxis to be ordred the reverseorder from the above graph, I tried using different options of 'classorder' which doesnt seems to have any effect.Kidnly help?

10 REPLIES 10
Jagadishkatam
Amethyst | Level 16

you can try the keylegend option as below

 

keylegend /title='PGI-S response categories:' valueattrs=(size=8) SORTORDER=DESCENDING;
Thanks,
Jag
Manj
Fluorite | Level 6
Thanks. This works only for legends and not colaxistable
DanH_sas
SAS Super FREQ

Will the REVERSE option on the COLAXIS statement give you what you want?

Manj
Fluorite | Level 6
I have tried all the options of CLASSORDER=DATA | REVERSEDATA | ASCENDING | DESCENDING and none were working
DanH_sas
SAS Super FREQ

Just to be clear: are you trying to change the order of the XAXIS or the XAXISTABLE? The original request said XAXIS, but the XAXISTABLE is circled.

Manj
Fluorite | Level 6
Sory if it confused you. Im interested in changing the order of colaxistable.
DanH_sas
SAS Super FREQ

To get what you want for the axis table, you will will need to presort the data and use REVERSEDATA on the CLASSORDER option. The PROC SORT will look something like the following:

 

proc sort data=data=&G_DDDATASETNAME;
by trt01p avisit avalc avalx;
run;

and the sorts on your VBAR and COLAXISTABLE statements will change:

 

proc sgpanel data=&G_DDDATASETNAME pctlevel=group ;
panelby trt01p / layout=columnlattice onepanel novarname colheaderpos=bottom headerattrs=(Size=8) ;
vbar avisit / group=avalc stat=percent grouporder=data attrid=avalc;
styleattrs datacolors=(white lightgrey darkgrey grey black) datacontrastcolours=( black black black black black);
colaxis display=(nolabel) valueattrs=(size=8);
rowaxis label='Percentage of Patients' ;
keylegend /title='PGI-S response categories:' valueattrs=(size=8);
colaxistable avalx / class=avalx classdisplay=stack stat=freq labelpos=right classorder=reversedata labelattrs=(size=8) valueattrs=(size=8);
run;

Hope this helps!

Dan

 

ballardw
Super User

@Manj wrote:
No Luck 😞

"No luck" is awful vague.

Are there errors in the log?: Post the code and log in a code box opened with the <> to maintain formatting of error messages.

No output? Post any log in a code box.

Unexpected output? Provide input data in the form of data step code pasted into a code box, the actual results and the expected results. Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the <> icon or attached as text to show exactly what you have and that we can test code against.

 

You may also need to examine which version of SAS you are running. The options in the graphics outputs are one of the fastest changing elements and if you are running an older version the options recommended may not suffice.

 

But Data and actual code really help diagnose things.The implication that you implemented @DanH_sas's suggestion does not mean that the code you submitted actually aligned with the suggestion. We have seen numerous examples of "doesn't work" and when we finally get the actual as ran code from a log find things like misspelled variables, order of by statements not matching, missing by variables and sometimes even errors that occur before the graphic procedure so that changes to data are not actually occurring so the procedure is still plotting the older data.

DanH_sas
SAS Super FREQ

You will need to presummarize the data and use VBARPARM instead of VBAR. That way the CLASSORDER option will be honored on the COLAXISTABLE statement. Here is an example:

 

proc summary data=sashelp.prdsale nway;
class year region product;
var actual;
output out=prdsale sum=;
run;

proc sort data=prdsale;
by year region product;
run;

proc sgpanel data=prdsale;
panelby year;
vbarparm category=region response=actual / group=product grouporder=data;
colaxistable actual / class=product classorder=reversedata;
run;

Hope this helps!

Dan

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 10 replies
  • 1385 views
  • 1 like
  • 4 in conversation