如何将包含平均值的列添加到SAS中的表中

时间:2015-11-12 22:58:26

标签: merge sas

假设这是我的数据集:

data test;
   input  Age ;
   datalines;
34 
28 
27 
36 
32 
39 
12 
32 
;

如何在此数据集中添加包含年龄列平均值的列?

2 个答案:

答案 0 :(得分:3)

使用PROC SQL;

proc sql;
create table test2 as
select age, 
       mean(age) as age_mean
from test;
quit;

如果没有GROUP BY语句,SQL会将均值返回到原始值。

答案 1 :(得分:1)

使用proc sql很容易得到它。

proc sql;
   select *,mean(age) as Age_mean from test;
quit;