The SAS Output Delivery System and reporting techniques

GTL: Barchart sorted by Frequencies

Reply
Occasional Contributor
Posts: 9

GTL: Barchart sorted by Frequencies

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;

PROC Star
Posts: 1,233

Re: GTL: Barchart sorted by Frequencies

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;
SAS Super FREQ
Posts: 8,743

Re: GTL: Barchart sorted by Frequencies

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

Occasional Contributor
Posts: 9

Re: GTL: Barchart sorted by Frequencies

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

Ask a Question
Discussion stats
  • 3 replies
  • 243 views
  • 0 likes
  • 3 in conversation