楼主: caliphcheng
8744 4

[问答] 关于format的用法 在data中和在各种proc中的用法 [推广有奖]

  • 0关注
  • 0粉丝

本科生

4%

还不是VIP/贵宾

-

威望
0
论坛币
5 个
通用积分
0.0173
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
1574 点
帖子
49
精华
0
在线时间
38 小时
注册时间
2012-4-10
最后登录
2016-12-8

楼主
caliphcheng 发表于 2012-9-28 10:32:03 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
我现在需要把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的方法

二维码

扫码加我 拉你入群

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

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

关键词:format FORMA form Data ROC

沙发
jingju11 发表于 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

藤椅
jingju11 发表于 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

板凳
caliphcheng 发表于 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上面能搜到么

报纸
00810112 发表于 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 ...
学习了

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-31 08:51