sas - How do I order the bars of a bar chart by height rather than alphabetically -


here's simple data set:

data dat;    = 1 100;       if      rand('unif') > 0.85 txt = 'defg';      else if rand('unif') > 0.75 txt = 'abc';      else if rand('unif') > 0.80 txt = 'klmnop';      else                             txt = 'hij';       output;   end;  run; 

i want create bar chart displays frequencies of txt:

proc sgplot data = dat; /* bars ordered alphabetically */    vbar txt; run; 

this creates this image

what i'd instead order bars height (from left right: hij, abc, defg, klmn).

is there option proc sgplot achieve that?

you can add option categoryorder in vbar statement:

proc sgplot data = dat;    vbar txt /categoryorder=respdesc ; run; quit; 

i found here: http://blogs.sas.com/content/graphicallyspeaking/2012/06/07/bar-chart-with-response-sort/#prettyphoto enter image description here


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -