Edu Ortiz
Edu Ortiz

Reputation: 23

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!

Upvotes: 1

Views: 3633

Answers (4)

abinash mishra
abinash mishra

Reputation: 11

%inc statements will execute the sas codes in sequence. 1)same tables or variables being used in script 1 and script 2 then it will get updated. 2) tables from script1 will be used in script2 but those must be available in work or any permanent libraries.

Upvotes: 0

gaurav2141
gaurav2141

Reputation: 130

%include will always run things in sequence.

If there is some variable being created in script1, then you can use the same in script2 but if script 1 is dependent of some variable being created in script 2, it will get error out.

Upvotes: 1

Ankit Mishra
Ankit Mishra

Reputation: 21

%include will run things in sequence. If your code in 1st %include hits an error then your program will stop and won't process other lines.

Upvotes: 1

Joe
Joe

Reputation: 63424

%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).

Upvotes: 4

Related Questions