Desktop productivity for business analysts and programmers

Running a program once a month

Reply
Contributor
Posts: 30

Running a program once a month

Dear all,

how would I check e.g. "First Saturday in current Month" or "Last Sunday in current Month"? I checked [pre]intnx[/pre] but couldn't find the solution there. With something like[pre]
%if weekday(today()) = 7 and day(today()) lt 8 %then %do;
...
%end;
[/pre]
I could solve this Problem; but is there a "nicer" way?

Thanks in advance,
Thomas
Super User
Posts: 5,391

Re: Running a program once a month

I think that your solution is quite neat, although the NWKDOM function may give an alternative. And to use functions with macro programming, you have to use the %sysfunc macro function.

Regards,
Linus
Data never sleeps
Respected Advisor
Posts: 4,137

Re: Running a program once a month

Hi Linus
What is this "NWKDOM" function? I don't know it and can't find it in the SAS OnlineDoc.
Cheers, Patrick
Super User
Posts: 5,391

Re: Running a program once a month

It is an ETS function that has moved to Base SAS with 9.2. Sorry, should have mentioned it.

/Linus
Data never sleeps
Contributor
Posts: 30

Re: Running a program once a month

Hi Linus,

thanks for your quick reply. Never heard of this function and as we are not using ETS I will have to use my solution.

Thanks and br,
Thomas
N/A
Posts: 0

Re: Running a program once a month

came across this a while ago:
http://support.sas.com/kb/24/655.html

it seems like some examples might be relevant for your needs.
Contributor
Posts: 30

Re: Running a program once a month

Great! Never heard of "week.2" etc.
This should solve my problem in an elegant way,

thanks,
Thomas
Contributor
Posts: 30

Re: Running a program once a month

Dear community,

exactly two years later I have a similar date-Problem: how to determine the last workday (Friday) on or before the 25th? Smiley Surprised)

Let's assume I have a variable d25cm (25th of current month). I tried with
[PRE]
data _null_;
WDB25=intnx('week.6',&d25cm,(weekday(&d25cm) in (2,3,4,5,6))-1);
if today() = WDB25 then do;
/* more code */
end;
run;
[/PRE]

but that doesn't work as expected. Any idea will be of great help!

With best regards,
Thomas
Contributor
Posts: 30

Re: Running a program once a month

I think I just found an easy solution (didn't know about the 'weekday' interval):
[PRE]
WDB25=intnx('weekday',d25cm,0);
[/PRE]

Thomas
Ask a Question
Discussion stats
  • 8 replies
  • 174 views
  • 0 likes
  • 4 in conversation