BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
BLarson
Obsidian | Level 7

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;

1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

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

3 REPLIES 3
DanH_sas
SAS Super FREQ

Use the REVERSE option on the XAXISOPTS:

 

xaxisopts=(reverse=true)

 

Hope this helps!

Dan

DanH_sas
SAS Super FREQ

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

BLarson
Obsidian | Level 7

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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 3 replies
  • 2680 views
  • 3 likes
  • 2 in conversation