BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I have a question regarding Rolling dates.

I have a column of payments and another one with dates associated with the payment.

example[/u
payments date
1200 5/5/05
1000 4/1/06
500 1/3/06

How do I calculate the rolling 12 months?


Message was edited by: Magnus at May 24, 2006 2:23 PM
Message was edited by: Magnus at May 24, 2006 2:26 PM
2 REPLIES 2
DaveShea
Lapis Lazuli | Level 10
Hi Magnus,

I'm not sure if this is specifically an Enterprise Guide question or not (I'm new to EG but am long-in-the-tooth on SAS).

Unless this is already solved, you may need to clarify it a little. For example you refer to two columns of dates but in your example I can only see one column.

Given a date eg 05May2006, what do you mean by "the rolling 12 months", do you mean 04May2007 or something more tricky, also, are you solely an EG point'n'click user or are you happy about writing a little datastep code?

Please let us know.

Cheers.
prholland
Fluorite | Level 6
Magnus,

This is pure Base SAS, not EG, so it will have to be pasted into a Code window (although it could also be constructed in a Query task), but I think it solves your problem:

data example;
informat payments best.
date mmddyy8.
;
format date date9.;
input payments date;
datalines;
1200 5/5/05
1000 4/1/06
500 1/3/06
150 6/7/06
run;

proc sql;
create table rolling as
select a.date
,sum(b.payments) as rolling_total
from example a
,example b
where b.date between a.date and mdy(month(a.date),day(a.date),year(a.date)-1)+1
group by
a.date
;
quit;

.........Phil

sas-innovate-2024.png

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.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 1147 views
  • 0 likes
  • 3 in conversation