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. 🙂
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.