Help using Base SAS procedures

INTNX function

Reply
Contributor
Posts: 22

INTNX function

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
Super Contributor
Posts: 359

Re: INTNX function

How about using 26 weeks?
x=intnx('week.2','16nov2009'd,-26);
Contributor
Posts: 22

Re: INTNX function

ahhh yes!!!

I tried like 7 different ways all but this! thanks!!!
Super Contributor
Super Contributor
Posts: 3,174

Re: INTNX function

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
Contributor
Posts: 22

Re: INTNX function

Sbb

"sameday" isn't useful. It was a left over experiment. my mistake. Thanks
Trusted Advisor
Posts: 2,115

Re: INTNX function

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.
Ask a Question
Discussion stats
  • 5 replies
  • 185 views
  • 0 likes
  • 4 in conversation