DATA Step, Macro, Functions and more

automating the execution?

SAS Employee
Posts: 73

automating the execution?

Q: If you want to execute a piece of SAS code only on the first Friday of every month, how will you achieve it? Write a sample code (in SAS) for the same.
Super User
Posts: 5,876

Re: automating the execution?

Posted in reply to Pavan_SAS
A: I suppose most schedulers has this functionality. But if you want to implement it using SAS, I suggest that you take a look at macro programming, together with the DAY and WEEKDAY functions.

Data never sleeps
Posts: 9,367

Re: automating the execution?

Posted in reply to Pavan_SAS
Look at step #9 in this paper:

This shows a particular report being submitted when the month is 6, 7 or 8 using a SAS Macro program. Your code would need to find and define a different date interval (probably using SAS functions)....but the overall approach would be similar.

I do suggest that you make sure you understand the code in steps 1-8 before jumping into step 9.

Super Contributor
Super Contributor
Posts: 3,176

Re: automating the execution?

Posted in reply to Cynthia_sas
Depending on your OS, there is likely an option for scheduling a "task" which would be to launch SAS and pass it your SYSIN which would contain the SAS program you want to execute.

Scott Barry
SBBWorks, Inc.

Suggested Google advanced search argument, this topic/post:

sas batch sysin
Posts: 36

Re: automating the execution?

Posted in reply to Pavan_SAS
Question is if you want to execute a complete program on Friday or just a section of code in a program only on Friday.
For the first you need a scheduler in your operating system.
For the second I would suggest some macro code.

data date_parms;
call symputx('dow',dow);

Macro variable dow is the day of week. Friday is day 6. Within the macro program you would use the following code.

%if &dow=6 %then
code segment;
Frequent Contributor
Posts: 91

Re: automating the execution?

Barheat - thanks for the day of week tip - I have been trying to use something like this but must have missed something along the way.

Pavan@SAS- We are running 9.2 on a remote server with XP, and this is how I get to the scheduler:

Start -> All Programs -> Accessories -> System Tools -> Scheduled Tasks

And in the run window I have the following all in one string:

-SYSIN D:\SASData\myarea\

Good luck!

Wendy T Message was edited by: WendyT
Ask a Question
Discussion stats
  • 5 replies
  • 6 in conversation