Data visualization with SAS programming

x axis order in PROC SGRENDER

Accepted Solution Solved
Reply
Contributor
Posts: 26
Accepted Solution

x axis order in PROC SGRENDER

I have the below proceedure.  I have sorted the x axis variable in decending order, it shows in the correct descending order in the dataset.  However when I run the Proc Template and subsequent Proc Sgrender steps the x axis is resorted in ascending order.  How can I keep the descending order.  Thank you.

PROC SORT DATA=WORK.ALLUP_PIPEHIST OUT=WORK.ALLUP_PIPEHIST1;

BY DESCENDING TIME_REF ;

FORMAT Pipe_Ct comma8.;

RUN;

*create bar chart of pipeline;

title;

footnote;

PROC TEMPLATE;

DEFINE STATGRAPH Pipe_App_Disp;

begingraph / DATACOLORS=(blue grey);

entrytitle 'Pipe / App / Disp History';

layout overlay / xaxisopts=(display=(ticks tickvalues))

yaxisopts=(griddisplay=off);

barchart x=TIME_REF y=Pipe_Ct /group=SOURCE stat=sum

GROUPDISPLAY=STACK dataskin=crisp BARWIDTH=.5 BARLABEL=TRUE BARLABELATTRS=(color=black weight=bold );

discretelegend 'a' / TITLE='Source:';

endlayout;

endgraph;

end;

run;

PROC SGRENDER DATA=WORK.ALLUP_PIPEHIST1 TEMPLATE=Pipe_App_Disp;

RUN;


Accepted Solutions
Solution
‎04-14-2016 02:50 PM
SAS Super FREQ
Posts: 864

Re: x axis order in PROC SGRENDER

[ Edited ]

Use the REVERSE option on the XAXISOPTS:

 

xaxisopts=(reverse=true)

 

To further elaborate:

 

When you use numeric data on a discrete axis (such as this bar chart case), the data is automatically forced to be in ascending numeric order. To make it descend, it is easiest to just use the REVERSE option. It is technically possible to create a string column containing the formatted numeric values, which will be rendered in DATA order (retaining your sort); but, for your case, using REVERSE is simpler.

 

Thanks!
Dan

View solution in original post


All Replies
SAS Super FREQ
Posts: 864

Re: x axis order in PROC SGRENDER

Use the REVERSE option on the XAXISOPTS:

 

xaxisopts=(reverse=true)

 

Hope this helps!

Dan

Solution
‎04-14-2016 02:50 PM
SAS Super FREQ
Posts: 864

Re: x axis order in PROC SGRENDER

[ Edited ]

Use the REVERSE option on the XAXISOPTS:

 

xaxisopts=(reverse=true)

 

To further elaborate:

 

When you use numeric data on a discrete axis (such as this bar chart case), the data is automatically forced to be in ascending numeric order. To make it descend, it is easiest to just use the REVERSE option. It is technically possible to create a string column containing the formatted numeric values, which will be rendered in DATA order (retaining your sort); but, for your case, using REVERSE is simpler.

 

Thanks!
Dan

Contributor
Posts: 26

Re: x axis order in PROC SGRENDER

Once again you have helped me tremendously.  I greatly appreciate your insights.  This worked perfectly.  You are going on my Christmas card list!!

Post a Question
Discussion Stats
  • 3 replies
  • 340 views
  • 3 likes
  • 2 in conversation