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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.