SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
Ashpak
Calcite | Level 5

Hi

 

I would like to schedule my SAS program on unix CRONTAB. i have scheduled for run my SAS program on 9pm. schedule to run only on specific days 18-30 and run on only Week days. here is i have setup of crontab

 

0 21 18-30 * 1-5 /workspace/lob5/alm/u021592/cron/ksh_file_name.ksh

 

but the problem is the program is running but its running on on Weekend as well (Sat and Sunday). But i dont want to run this on SAT and SUN. i have listed 1-5 for some reason both day of month and day of week together not working?

 

Appreciate your help on this  or any other approach?

5 REPLIES 5
yabwon
Onyx | Level 15

For start you can add something like this:

%put &=sysday.;
%macro stopSAS()/minoperator;
%if &sysday. in (Saturday Sunday) %then
%do;
  endsas;
%end;
%mend;
%stopSAS()

at the beginning of your SAS code.

 

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



Ashpak
Calcite | Level 5

Thanks Is this code we need be written  in SAS program ? or Unix Shell scripts like crontab -e options?

SASKiwi
PROC Star

You can configure crontab to only run on certain days of the week: https://stackoverflow.com/questions/18919151/crontab-day-of-the-week-syntax

 

This is a lot better than handling this in your SAS program. If you google "crontab days of the week" you should find out the right syntax.

km19922
Calcite | Level 5

Thanks, I have the same problem in my company when scheduling a cron job

Tom
Super User Tom
Super User

Probably a question you should ask on a different forum.

Perhaps cron is not smart enough to filter by both specific days of the month and specific days of the week?

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1947 views
  • 0 likes
  • 5 in conversation