BookmarkSubscribeRSS Feed
Pavan_SAS
SAS Employee
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.
5 REPLIES 5
LinusH
Tourmaline | Level 20
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.

/Linus
Data never sleeps
Cynthia_sas
SAS Super FREQ
Hi:
Look at step #9 in this paper:
http://www2.sas.com/proceedings/sugi28/056-28.pdf

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.

cynthia
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
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 site:sas.com
barheat
Fluorite | Level 6
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;
dow=put(today(),weekday1.);
call symputx('dow',dow);
run;

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
%do;
code segment;
%end;
WendyT
Pyrite | Level 9
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:

D:\SAS9.2\SASFoundation\9.2\sas.exe
-AUTOEXEC D:\SASData\myarea\AUTOEXEC.SAS
-SYSIN D:\SASData\myarea\run_this_file.sas

Good luck!

Wendy T Message was edited by: WendyT

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 1333 views
  • 0 likes
  • 6 in conversation