We’re smarter together. Learn from this collection of community knowledge and add your expertise.

How to link a sequence of SAS Enterprise Guide projects

by Regular Contributor ‎02-26-2018 11:30 AM - edited ‎02-27-2018 12:06 PM (2,089 Views)

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;
     format endit b8601dt.;

 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;
    format start b8601dt.;

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;


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

    %put &=proj2start &=proj1ended;

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

/*    CALL WAIT(60); sorry...didn't realize wait doesn't work! */
	data _null_;

    %goto again;


%put &=proj2start &=proj1ended;

%mend loop;





by Moderator
on ‎03-06-2018 08:37 PM

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..]

by Regular Contributor
on ‎03-08-2018 08:08 AM

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.

Your turn
Sign In!

Want to write an article? Sign in with your profile.

Looking for the Ask the Expert series? Find it in its new home: communities.sas.com/askexpert.