假设这是我的数据集:
data test;
input Age ;
datalines;
34
28
27
36
32
39
12
32
;
如何在此数据集中添加包含年龄列平均值的列?
答案 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;