BookmarkSubscribeRSS Feed
Calcite | Level 5



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?

Onyx | Level 15

For start you can add something like this:

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

at the beginning of your SAS code.



Polish SAS Users Group: and

"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

Calcite | Level 5

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


You can configure crontab to only run on certain days of the week:


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.

Calcite | Level 5

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

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?

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 5 in conversation