全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
8667 4
2012-09-28
我现在需要把proc means的mean的结果以一位小数的形式显示,我的代码是这样的:

我先用这个代码:
proc means mean data=cars;
var reliable 5.1   millage 5.1 ;
run;

然后LOG报错

然后我用这个代码:
proc means mean data=cars;
var reliable  millage ;
format reliable 5.1 millage 5.1;
run;
得出来的也不是一位小数:
reliable
millage
2.8750000
25.7500000


然后我用很蛋疼的方法,把proc means的结果输出成新的dataset,然后再用set和各种选择语句把reliable和millage的mean选出来做成另一个dataset,然后在proc print的时候format:
proc means mean data=cars;
var reliable  millage ;
output out=m;
run;
data m1;
set m;
if _STAT_='MEAN';
keep _STAT_ reliable millage;
run;
proc print data=m1;
format reliable 5.1 millage 5.1;
run;

Obs_STAT_reliablemillage
1MEAN2.925.8

这样虽然能成,但是太复杂了,求能在第一次proc means的时候就能format的方法

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2012-9-28 10:38:33
reason is that proc means does not appreciate formats. if only for output, using maxdec=1 in means statement.jingju
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2012-9-28 10:49:38
more words, you got to think it through,format statement oftentimes works before calculation. but you were asking the format on the output. so you won't get the convenience here. so, when you think SAS works awkwardly , it may be because of your awkward requirement. no offence here. jingju
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2012-9-28 11:04:04
jingju11 发表于 2012-9-28 10:49
more words, you got to think it through,format statement oftentimes works before calculation. but yo ...
真的可以了也,只有一位小数了,好神奇,大神们都怎么知道的这种细节的小代码啊,support.sas.com上面能搜到么
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2012-9-29 10:05:20
jingju11 发表于 2012-9-28 10:38
reason is that proc means does not appreciate formats. if only for output, using maxdec=1 in means s ...
学习了
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群