BookmarkSubscribeRSS Feed
Pyrite | Level 9

In my company, I run a process once a month after another one is finished. To know that it is finished, I manually look at the following table (it has about 100 more rows in reality): 


Latest date for finishing the process Date when the process was finished Process has begun
31-jan-22 05-jan-22 1
28-feb-22 04-feb-22 1
31-mar-22 03-mar-22 1
30-apr-22 05-apr-22 1
31-maj-22 . 0
30-jun-22 . 0
31-jul-22 . 0
31-aug-22 . 0
30-sep-22 . 0
31-okt-22 . 0
30-nov-22 . 0
31-dec-22 . 0
31-jan-23 . 0
28-feb-23 . 0
31-mar-23 . 0
30-apr-23 . 0


Assuming we are currently standing in april-2022. 

Since there is a date (05-apr-22) in the column "Date when the process was finished" I know that the process has been finished and I can run my process. An extra sanity check is that the column "Process has begun" should have a 1 in the row for the relevant month. So if there is a date in the relevant row I should run my process. BUT, this should only be done once every month.

Next month, in May I will every day look when the middle column gets an date: 

31-maj-22 . 0


when it has I will run my process. 

Obviously, this is a manual process that can be automatized and my goal is to set up an SAS Program that perfroms the test (say once day) which will be done automatically by scheduling the SAS program. Any advice how I could write a SAS program to perform the desired test? I also want to emphasize, that if we are standing in april 2022 for instance: 

30-apr-22 05-apr-22 1

then the 05-apr-22 I could run my process, but I should not run it anymore that month, so I should continue to next month and check when there comes an date. 
I also know that in the column "Date when the process was finished", when there is something filled up it should be the same month and year as in the column: Latest date for finishing the process. Else something is wrong. 

I hope it is clear what I mean, appreciate your help! 

Tourmaline | Level 20

The easiest way is:

1- In the first process, once everything is OK, write out a text file somewhere.

2- The second process can start at the same time, and checks every few minutes that the file exists.

  Once the file is found, exit the waiting loop and run the rest of the code.

Pyrite | Level 9
1. Unfortunately not possible since it is a process I have no control over and cannot affect.
2. This as far as I can see could lead to my process beeing run several times a month, it should only be run once.
Meteorite | Level 14

In the corporate environment schedulers (Autosys, Contol-M etc) take care of this. Starting the second job after the first has finished.
If that is not possible in your case and if you are on a  Unix/Linux environment you can write a batch script that can do this job.
If either of the above two are not possible then the suggestion by @ChrisNZ is your best choice..

Tourmaline | Level 20

 Unfortunately not possible since it is a process I have no control over and cannot affect.

The next best method then, if your scheduler can't link jobs, could be to check the file:
- Check the sas date set's (file *.sas7bdat) update date.
- It it has been updated, open it and validate the data.

You need these 2 steps as doing only step 2 could lock the data set just when job1 wants to upate it.

This as far as I can see could lead to my process beeing run several times a month

I don't see why.


Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.


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
  • 4 replies
  • 3 in conversation