LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (May 2008, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Sun, 18 May 2008 09:41:10 -0400
Reply-To:   Michael Raithel <michaelraithel@WESTAT.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Michael Raithel <michaelraithel@WESTAT.COM>
Subject:   Re: updating a sas dataset by multiple jobs
In-Reply-To:   <>
Content-Type:   text/plain; charset="us-ascii"

Dear SAS-L-ers,

Siva Rao posted the following interesting question:

> Hi , I am trying to read/write a SAS dataset by multiple jobs > running concurrently. Here are some details on my task that I > am trying to achieve: > > 1. I will run my process on UNIX and using sas9.x > 2. I will create a sas dataset (permanent dataset) called > "control" with 2 > columns: > JOb_name and FLAG. > > 3. I have total 4 jobs, JOB1, JOB2, JOB3, JOB4 to run. > and I like to submit all 4 using SYSTASK COMMAND to run > consurrently. > At the very end of JOB1, JOB2, and JOB3, I will > insert/write a record to "control" > dataset to mark the completion of the job. For example as below: > > Proc sql; > insert into X.control values('JOB1','1'); > quit; > > > JOb4 should run only after the successful completion of > JOB1, JOB2, JOB3. > So, in JOB4 I am using sleep commmand so that It will be > active in the > background and will keep checking the "CONTROL" dataset (created in > step2) for the JOb_name and FLAG and if it finds that > JOB1, JOB2, JOB3 > are completed then Job should start processing. > > > My question is : How can I make the "CONTROL" dataset > available for JOB1/2/3 for wrting > and available to JOB4 for reading without > any deadlock or without failing the jobs and > without any data inconsistency? > > Can you please help me? THANK YOU SO MUCH in advance. > Siva, I would take a slightly different approach in addressing your stated issues with the running of these four jobs. Here is what I would do:

1. Recode Job1, Job2, and Job3 so that each of them did the following at the end of the job:

a. Checked to see if the CONTROL data set was available--not being exclusively held by another job

b. If the CONTROL data set was not available, go into a sleep mode for a bit and then see if it was available again. Keep doing this until it could access the CONTROL data set.

c. If the CONTROL data is available, write the relevant message to it.

d. After writing the relevant message to the CONTROL data set see if all three of the relevant messages have been written to the CONTROL data set. If so, write a message for Job4 and submit Job4 for execution.

e. If the CONTROL data set is available and there is a message for Job4, do not submit Job4 for execution.

Consequently, Jobs 1 - 3 would be responsible for submitting Job4 if and only if all three jobs had written to CONTROL and none of them had previously submitted Job4. Also, you might need an additional column for date/time and have to include that in your checking routine. Capiche?

So, you are thinking to yourself "how the heck can I tell whether of not the CONTROL data set is in use?", right? Well, in my SUGI 30 Paper, Automatically Process a Varying Number Of New Data Files From a "Data Directory", <<>> I have the following code snippet:

***************************; * Allocate the Data file. *; ***************************; filename DATAFIL "&DATAFIL";

*****************************************; * Determine if the Data file is in use. *; *****************************************; data _null_;

inuse = fopen('DATAFIL');

call symput('INUSE',inuse);

if inuse = 0 then do; put '*** Attention: the file below was in use ***'; put '*** and could not be processed ***'; put "&DATAFIL"; put _all_; put '*** Attention: the file above was in use ***'; put '*** and could not be processed ***'; end; run;

... code something analogous for a SAS data set. If not, and you like it, then change CONTROL to a flat file. Oh, and, either way, you will obviously be modifying the DATA _NULL_ step, above to suit your nefarious needs!

Siva, best of luck getting your SAS jobs up and running in their proper order on UNIX!

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Michael A. Raithel "The man who wrote the book on performance" E-mail:

Author: Tuning SAS Applications in the MVS Environment

Author: Tuning SAS Applications in the OS/390 and z/OS Environments, Second Edition

Author: The Complete Guide to SAS Indexes

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Common sense is the collection of prejudices acquired by age eighteen. - Albert Einstein +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Back to: Top of message | Previous page | Main SAS-L page