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;
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 lock in 2025 pricing—just $495!
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.