Reputation: 40513
Here's a simple data set:
data dat;
do i = 1 to 100;
if rand('unif') > 0.85 then txt = 'DEFG';
else if rand('unif') > 0.75 then txt = 'ABC';
else if rand('unif') > 0.80 then txt = 'KLMNOP';
else txt = 'HIJ';
output;
end;
run;
I want to create a bar chart that displays the frequencies of txt
:
proc sgplot data = dat;
/* Bars are ordered alphabetically */
vbar txt;
run;
What I'd like instead is to order the bars by height (from left to right: HIJ, ABC, DEFG, KLMN).
Is there an option to proc sgplot
to achieve that?
Upvotes: 2
Views: 410
Reputation: 1396
You can add option categoryorder in your vbar statement:
proc sgplot data = dat;
vbar txt /categoryorder=respdesc ;
run; quit;
I found it here: http://blogs.sas.com/content/graphicallyspeaking/2012/06/07/bar-chart-with-response-sort/#prettyPhoto
Upvotes: 2