假设这是我的数据集:
data test;
input Age ;
datalines;
34
28
27
36
32
39
12
32
;
如何将包含年龄列平均值的列添加到此数据集中?
使用PROC SQL;
proc sql;
create table test2 as
select age,
mean(age) as age_mean
from test;
quit;
如果没有GROUP BY语句,SQL将把均值与原始值合并。
使用proc-sql很容易获得它。
proc sql;
select *,mean(age) as Age_mean from test;
quit;