【问题标题】:How do I order the bars of a bar chart by height rather than alphabetically如何按高度而不是按字母顺序排列条形图的条形
【发布时间】:2017-09-11 05:25:42
【问题描述】:

这是一个简单的数据集:

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;

我想创建一个显示txt 频率的条形图:

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

这会创建

我想要的是按高度排序条形(从左到右:HIJ、ABC、DEFG、KLMN)。

有没有proc sgplot 的选项来实现这一目标?

【问题讨论】:

    标签: sas bar-chart


    【解决方案1】:

    您可以在 vbar 语句中添加选项 categoryorder

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

    我在这里找到它:http://blogs.sas.com/content/graphicallyspeaking/2012/06/07/bar-chart-with-response-sort/#prettyPhoto

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-18
      • 1970-01-01
      • 2020-02-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多