Search code examples
sas

Running SAS script using %include


I'm newbie in SAS, coming from SQL, so I'm dealing with them differences.

I have a SAS program "Master.sas" that runs, among other things, something like this:

%include "c:\script1.sas";
%include "c:\script2.sas";
%include "c:\script3.sas";

The question is, if I select all of them and run it, does it run sequentially or in parallel? For example, if script2 uses a table that is loaded in script1, will it fail to run succesfully? Well, that example maybe sound obvious as I tested, but what happens if script1 calculate a variable, script2 will have the variable calculated or uses what it found at run time (because, for example, script2 has runned previously than script1)? Just to clarify, I need that SAS run them sequentially, one after other.

In SQL exists "GO" to separate batch processing, i.e.:

CREATE TABLE XXXXX
GO

SELECT * FROM XXXXX
GO

If someone tries to run that script with out GO, SQL runs them in parallel producing an error on the second script telling that "table XXXXX doesn't exist".

Do I need something similar in SAS or SAS just process next when the previous has finished?

Thanks in advance!


Solution

  • %include will run things in sequence. SAS will run the first %include as if it were just lines in the code, then hit the second and do the same, etc.

    SAS's equivalent of GO is RUN, by the by, though in most cases RUN doesn't actually have to be included (though it's considered a good practice). SAS will not run in parallel mode just because you leave out RUN, but it is what tells SAS to go ahead and run the code that was given it. This does not apply in PROC SQL, however; that does not support run-group processing, and instantly executes each statement terminated by ;.

    There are ways to make it run in parallel; for example, this hands-on workshop from SUGI 29 on Parallel Processing shows how to use RSUBMIT to do so. Enterprise Guide allows for parallel processing of programs (but not %includes in one program) if you tell it to (but not by default).