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;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.