标题: 做sas条形图时,如何根据条形的长短自动排序... [打印本页] 作者: shiyiming 时间: 2011-10-8 12:01 标题: 做sas条形图时,如何根据条形的长短自动排序... 如标题,不知道有没有什么选项之类的,做出的条形图是根据pf的大小从左到右,
或从上到下的顺序显示出来的,而不是根据tm的顺序来显示的...测试数据集如下:
data test;
input tm $ pf;
cards;
VAR00001 4.49
VAR00002 3.61
VAR00003 4.54
VAR00004 4.66
VAR00005 5.38
VAR00006 4.43
;作者: shiyiming 时间: 2011-10-8 12:14 标题: Re: 做sas条形图时,如何根据条形的长短自动排序... 把pf的值显示在条形柱上边的话更好...作者: shiyiming 时间: 2011-10-8 13:22 标题: Re: 做sas条形图时,如何根据条形的长短自动排序... 不可以先排序吗?显示值的话可以考虑ANNOTATE作者: shiyiming 时间: 2011-10-8 14:17 标题: Re: 做sas条形图时,如何根据条形的长短自动排序... [quote="yugao1986":fxwlh78r]不可以先排序吗?显示值的话可以考虑ANNOTATE[/quote:fxwlh78r]
先排序不行,试过了...作者: shiyiming 时间: 2011-10-12 03:51 标题: Re: 做sas条形图时,如何根据条形的长短自动排序... 可以参考以下程序.遗憾的是这些过程好象无法直接采用顺序等选项.京剧
[code:2ixuz7nz]proc sort; by pf tm;
data test;
retain fmtname 'tmFmt';
set test;
start ++1;
label =tm;
run;
proc format cntlin =test(keep =fmtname start label);
run;
proc sgplot data =test;
vbar start/response =pf datalabel;
format start tmFmt.;
yaxis label ='pf';
xaxis label ='tm';
run;
quit;[/code:2ixuz7nz]作者: shiyiming 时间: 2011-10-12 18:42 标题: Re: 做sas条形图时,如何根据条形的长短自动排序... 谢谢京剧版主,我在运行时后,参数datalabel参数不可识别,请求怎么办呢。。。用的9.2版的,把datalabel去掉后,系统不出错,但没图形
67 proc sgplot data =test;
68 vbar start/response =pf datalabel;
---------
22
202
ERROR 22-322: 语法错误,期望下列之一: ;, ALPHA, BARWIDTH, FILL, FILLATTRS, FREQ, GROUP, LEGENDLABEL, LIMITS, LIMITSTAT,
MISSING, NAME, NOFILL, NOOUTLINE, NUMSTD, OUTLINE, RESPONSE, STAT, TRANSPARENCY, URL, WEIGHT.
ERROR 202-322: 该选项或参数不可识别,将被忽略。
69 format start tmFmt.;
70 yaxis label ='pf';
71 xaxis label ='tm';
72 run;作者: shiyiming 时间: 2011-10-12 20:07 标题: Re: 做sas条形图时,如何根据条形的长短自动排序... Very interesting.
For VBAR/HBAR statement, version 9.2 is high enough. I think that came with SGPLOT while DATALABEL option may need 9.2.2.
JingJu作者: shiyiming 时间: 2011-10-13 12:39 标题: Re: 做sas条形图时,如何根据条形的长短自动排序... [quote="jingju11":20izzobv]Very interesting.
For VBAR/HBAR statement, version 9.2 is high enough. I think that came with SGPLOT while DATALABEL option may need 9.2.2.
axis1 label=(angle=90 "PF Values");
proc gbarline data=test;
bar tm/discrete sumvar=pf descending inside=sum raxis=axis1;
format pf 7.2;
label tm="";
run;
goptions reset=all;
[/code:16mp1jtn]
<!-- s:) --><img src="{SMILIES_PATH}/icon_smile.gif" alt=":)" title="Smile" /><!-- s:) -->
[quote="sas_studying":16mp1jtn][quote="jingju11":16mp1jtn]Very interesting.
For VBAR/HBAR statement, version 9.2 is high enough. I think that came with SGPLOT while DATALABEL option may need 9.2.2.