BookmarkSubscribeRSS Feed
Hart
Calcite | Level 5
I am trying to find a date 6 months prior to inputted date. HOWEVER the final date should fall on a monday.

I run a report each monday & need to extract 6-months of data beginning on the monday closest to the 6 month point. so it could be a little over/under 6mo of data.

ex. this week i ran a report as of 11/16/09 & selected the begin date as 5/18/09 because its the closest Monday to (6-mon prior) Saturday 5/16.

tried x=intnx('month','16nov2009'd,-6, "sameday"); but of course this will not automatically return a monday date. Thought of combining this with a weekday function.

is this possible? any thoughts
5 REPLIES 5
Flip
Fluorite | Level 6
How about using 26 weeks?
x=intnx('week.2','16nov2009'd,-26);
Hart
Calcite | Level 5
ahhh yes!!!

I tried like 7 different ways all but this! thanks!!!
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
A SAS numeric DATE variable is a count of the number of days since 1/1/1960. So, yes, you can add/subtract either using an assignment statement and/or using the INTNX function. My choice would be a combination of INTNX and using the WEEKDAY function, determine whether to add or subtract, since you mentioned the need for "closest" Monday. Personally, I don't see how the sameday operand helps in your quest, though.

Scott Barry
SBBWorks, Inc.

SAS Language Reference: Dictionary, Date and Time Intervals
http://support.sas.com/documentation/cdl/en/lrdict/62618/HTML/default/a003065889.htm#a003065892
Hart
Calcite | Level 5
Sbb

"sameday" isn't useful. It was a left over experiment. my mistake. Thanks
Doc_Duke
Rhodochrosite | Level 12
An easy thing that you could try is to use 26 weeks. In intck, WEEK26.2 would get you 6 months starting on a Monday. You'll have to test it with different starting dates to see if the equivalency is adequate to the business need.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

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.

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
  • 5 replies
  • 870 views
  • 0 likes
  • 4 in conversation