王笑权 data pye; input a @@; d5=(1/pdf('norm',0))**2/2; format d5 18.15;/*指定输出15位小数|put d5 18.15*/ cards; -3 -2.58 -1.96 -1 0 1 1.96 2.58 3 ; proc print; run;
seu0310 谢谢;)我查询了SAS手册,在means过程中可以用maxdec语句;在univariate过程可以用round语句;在data步可以用format语句定义,但在输出到具体格式时会出现问题:在用format语句输出到EXCEL文件时,还是没有起到保留小数位数的作用,在SAS数据集中显示的是保留小数位数的状态,而在输出到WORD文件时,这种format语句是起到保留小数位数的作用了;在用round语句输出到EXCEL文件时就能保留小数位数。 再说声谢谢!
millwood Or use put function, for example: Mean=put(age_mean, 4.1); percentage=put(percent/100, percent10.1); Probt1=put(Probt, pvalue6.4); Converting Numeric Values to Character Value then output Character value to EXCEL. It is easier to control character value format in EXCEL (no surprise due to internal EXCEL numerical value format).
王笑权 data pye; input a @@; d5=(1/pdf('norm',0))**2/2; format d5 18.15;/*指定输出15位小数|put d5 18.15*/ cards; -3 -2.58 -1.96 -1 0 1 1.96 2.58 3 ; data b;set pye;file '桌面\小数.xls'; put a d5; proc print; run; 我刚才用该程序试验:txt,doc,xls都获得成功。
tomquercio [quote]引用第0楼seu0310于2008-06-05 20:55发表的“在SAS中如何将输出数据结果保留两位小数?”: 在SAS中如何将输出数据结果保留两位小数? [/quote] parameter = round(parameter,0.01);
tctcab GFW printf大法好 sprintf("%.5f", 2.04999999) #> [1] "2.05000" <sup>Created on 2019-10-21 by the reprex package (v0.3.0)</sup>
GFW 感谢两位大佬@tctcab @nan.xiao 的解答,这个问题在另一个帖子里也已经得到@nan.xiao 和@ryo 的解答。 链接如下:https://d.cosx.org/d/411299-411299/8