I hope I'm not missing an easy answer, but it's not for lack of diligence. I'm trying to use GTL to define a fairly basic horizontal bar chart. For the life of me I can't find an option to allow me to sort the bars by frequency. Is there an equivalent GTL option to CATEGORYORDER=RESPDESC? I suspect there is since this is would be a common need.
proc template;
define statgraph FlagBarCharts;
dynamic byvar;
begingraph;
entrytitle "Flag Variable: " byvar ;
layout overlay
/ border=false
WALLDISPLAY=none
xaxisopts=(
label=' '
linearopts=(viewmax=10));
BARCHARTPARM x=subcat y=percent
/ orient=horizontal;
endlayout;
endgraph;
end;
run;
Hi
I'm new to GTL, but I think if you remove the linearopts= option, then the categories will be ordered according to the order of the input dataset. I guess when you added linearopts=, it forced the xaxis to be linear, instead of categorical.
proc template; define statgraph FlagBarCharts; dynamic byvar; begingraph; entrytitle "Flag Variable: " byvar ; layout overlay / border=false WALLDISPLAY=none xaxisopts=( label=' ' ); BARCHARTPARM x=subcat y=percent / orient=horizontal ; endlayout; endgraph; end; run; data in; subcat='1'; percent=2; output; subcat='2'; percent=6; output; subcat='3'; percent=4;output; run; proc sort data=in; by percent; run; ods pdf file="d:\junk\me.pdf"; proc sgrender data=in template=FlagBarcharts; run; ods pdf close;
Hi,
And for more feedback from the heavy hitters and graph gurus in the ODS Graphics area, I recommend posting and looking in the forum that is dedicated to ODS GRAPHICS.
cynthia
Since its a horizontal chart, the linear opts correspond the the response. Removing that doesn't alter the category sorting.
So to re-post it there, should I just copy/paste my message, or is there a way to do that in the software? I guess I'll copy-paste. Thanks !
Bob
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.
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.