BookmarkSubscribeRSS Feed
bob_pearson
Calcite | Level 5

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;

3 REPLIES 3
Quentin
Super User

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;
BASUG is hosting free webinars Next up: Mike Sale presenting Data Warehousing with SAS April 10 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
Cynthia_sas
SAS Super FREQ

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

bob_pearson
Calcite | Level 5

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

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
  • 907 views
  • 0 likes
  • 3 in conversation