输入/打印变量的平均值以登录 SAS [英] Put/print mean of a variable to log in SAS

查看:35
本文介绍了输入/打印变量的平均值以登录 SAS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 SAS 中将变量的均值打印到日志中?

How do i print the mean of a variable to the log in SAS?

data fruit;
input zip fruit & $22. pounds;
datalines;
10034 apples, grapes kiwi  123456
92626  oranges  97654
25414 pears apple      987654
;

这是我试过的:

data _null_;
   set fruit;
   put mean(zip);
run;

推荐答案

您可以使用 PROC SQL.

You can use PROC SQL.

proc sql noprint; 
/*noprint as you don't want to print to the defined output location, just the log*/

/*format, formats the value.  into :<> puts the value into a macro variable named <>*/
select mean(zip) format=best32.
   into :zip_mean
   from fruit;

/*%put writes a message to the log*/
%put Mean of Zip: &zip_mean;
quit;

如果您可以将值写入打开的输出位置,则只需使用:

If you are OK writing the value to the open output location then just use:

proc sql;
select mean(zip) format=best32.
   from fruit;
quit;

这篇关于输入/打印变量的平均值以登录 SAS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆