Hello,
Can anyone help me with the following?
I have the following data set and I'm trying to get the average by Id for the entire year.
dataset:
date | id | amount |
jan | a1 | 10 |
jan | a2 | 4 |
jan | a3 | 2 |
feb | a1 | 6 |
feb | a2 | 4 |
feb | a3 | 8 |
march | a1 | 6 |
march | a2 | 5 |
march | a3 | 1 |
what I'm trying to get:
id | average |
a1 | 7.3 |
a2 | 4.3 |
a3 | 3.6 |
Thanks!
proc sql;
create table want as
select id, avg(amount) as average
from have
group by id;
quit;
PROC MEANS/PROC SUMMARY
Example:
proc sql;
create table want as
select id, avg(amount) as average
from have
group by id;
quit;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.