New to SAS.
I currently need to summarize some data and know what is the average price of each month.
I have data like this:
Date / Price
19-05-23 50
19-05-23 80
19-05-24 50
19-05-25 ..........cont.
I would like to have a dataset like this:
Month / Average Price
May 2019 70
Jun 2019 90 ....
Please help! A million thanks!!
Hi @vitalam89
SQL is very simple too
data have;
input date :date9. price;
format date date9.;
cards;
01jul1994 10
02may1995 15
10may1995 20
16jun1995 25
28jun1995 30
;
proc sql;
create table want as
select put(date,monyy7.) as Month_year, avg(price) as Average_price
from have
group by Month_year;
quit;
Welcome to the SAS Community 🙂
Do something like this
data have;
input date :date9. price;
format dates date9.;
cards;
01jul1994 10
02may1995 15
10may1995 20
16jun1995 25
28jun1995 30
;
proc summary data=have nway;
class date;
format date monyy7.;
var price;
output out=want(drop=_TYPE_ _FREQ_) mean=;
run;
Hi @vitalam89
SQL is very simple too
data have;
input date :date9. price;
format date date9.;
cards;
01jul1994 10
02may1995 15
10may1995 20
16jun1995 25
28jun1995 30
;
proc sql;
create table want as
select put(date,monyy7.) as Month_year, avg(price) as Average_price
from have
group by Month_year;
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!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.