Reputation: 339
Assume this is my dataset:
data test;
input Age ;
datalines;
34
28
27
36
32
39
12
32
;
How can I add a column to this dataset which contains the average value of the age column?
Upvotes: 1
Views: 820
Reputation: 12465
Use PROC SQL;
proc sql;
create table test2 as
select age,
mean(age) as age_mean
from test;
quit;
Without a GROUP BY statement, SQL will merge the mean back with the original values.
Upvotes: 3
Reputation: 4554
It is easy to get it with proc sql.
proc sql;
select *,mean(age) as Age_mean from test;
quit;
Upvotes: 1