BookmarkSubscribeRSS Feed

How to link a sequence of SAS Enterprise Guide projects

Started ‎02-26-2018 by
Modified ‎02-27-2018 by
Views 5,104

Here's how to have a second project kick off after the successful completion of the first project (2 separate SAS EG sessions).

 

1.At the end of project1, have it overwrite an existing dataset in a commonly accessible permanent folder. 

 

data common.proj1ended;
     ended=datetime();
     format endit b8601dt.;
RUN;

 2. At the beginning of project2, have it create a new temp dataset called 'start' to store the starting time of project2.

  

data work.start;
    start=datetime();
    format start b8601dt.;
RUN;

3. Then, in project2, read 'start' from work.start and check the modified date of 'proj1ended'

 

If the modified date of proj1ended is less than 'proj2start', wait 60 seconds and check again.

 

Have this program linked to the next program of your process flow so that once the modified date of proj1ended exceeds the starttime of project2, the rest of project2 will continue. 

 

%macro loop;

    proc sql;
        select start format=b8601dt. into :proj2start trimmed from work.start;
    quit;

%again:

    proc sql;
        select modate format=b8601dt. into :proj1ended trimmed from DICTIONARY.tables
            where libname='COMMON' and memname='PROJ1ENDED';
    quit;

    %put &=proj2start &=proj1ended;

    %if &proj1ended > &proj2start %then
        %goto ready;

/*    CALL WAIT(60); sorry...didn't realize wait doesn't work! */
	data _null_;
		rc=sleep(60,1);
		run;

    %goto again;


%ready:     


%put &=proj2start &=proj1ended;


%mend loop;


%loop;

 

 

 

Comments

So, attempting to handshake from one program to another..

 

Presumably you'd kick of both EG sessions, and have #2 wait for the handshake from #1.

 

(Also means these two can run on different EG clients, and could even run on different SAS servers/environments, as long as they have access to the common data set - nice touch!)

 

In some sites, the EG connection will timeout after a period of inactivity - what then? EG is really there for interactive sessions, not batch (or triggered) tasks - why interactively run 2 interconnected EG sessions? Would #1 calling a stored process be an alternative in this case?

 

[Also, personal comment from my C & Pascal days - was never a fan of "Goto" statements, much prefer loops, but that's me..]

It's my attempt to overcome the limitation within EG to daisy-chain flows. 

 

You could do them within a single EG session as well, kicking off the 2nd flow after the 1st. 

 

My initial circumstance was to handle 2 different reports that depend on a common set of datasets that need to be refreshed daily.

 

It could certainly be done with stored processes as well.

 

I'm fond of loops as well, but also fond of goto. 🙂

 

As always, YMMV.

This should jump-start some work I'll have to do in a few weeks.  Thanks for sharing it.

 

John

Version history
Last update:
‎02-27-2018 12:06 PM
Updated by:
Contributors

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Free course: Data Literacy Essentials

Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning  and boost your career prospects.

Get Started

Article Labels
Article Tags