Hi,
I have monthly sales data for 33 markets for 5 years, I want to calculate FYTD sales.
For us the Financial Year starts from month of April and ends in March.
e.g. FYTD for October 2017 will be sum of sales from April 17 to Oct 17.
So I have to create a variable named as FYTD and corresponding to each month it will have FYTD sales.
Can i try it using proc expand.
--
Here's an example using the monthly data series sashelp.stocks, which I sort because it is stored in reverse chronological order.
proc sort data=sashelp.stocks (keep=stock date volume) out=have;
by stock date;
run;
data want;
set have;
by stock;
Fytd_vol+volume; format fytd_vol comma13.0;
if intck('year.4',lag(date),date) then fytd_vol=volume;
else if first.stock then fytd_vol=volume;
run;
Here's an example using the monthly data series sashelp.stocks, which I sort because it is stored in reverse chronological order.
proc sort data=sashelp.stocks (keep=stock date volume) out=have;
by stock date;
run;
data want;
set have;
by stock;
Fytd_vol+volume; format fytd_vol comma13.0;
if intck('year.4',lag(date),date) then fytd_vol=volume;
else if first.stock then fytd_vol=volume;
run;
Thanks Mkeintz, i tried it in the similar way. 🙂
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Early bird rate extended! Save $200 when you sign up by March 31.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.