Guilherme Zerbini
Guilherme Zerbini

Reputation: 17

Run SAS Program (Inside the SAS project) with lines of code

I'm trying to automate my SAS code. In a project i have several programs, and i would like to have one program that can call some of the previous ones. The ideia is to make a condition that when true call a specific program.

Upvotes: 0

Views: 881

Answers (2)

Richard
Richard

Reputation: 27498

You can use call execute in DATA step to dispatch the code to run a program.

Suppose you have a control table listing the programs that are available to run:

PERM.PROGRAMS
-------------
runit program
----- -------------------------------------
yes   /project1/step1.sas
 no   /project1/step1extra.sas
yes   /project1/step2.sas

data _null_;
  set perm.programs;
  if runit='yes' then 
    call execute ('%include ' || quote(program,"'"));
run;

Upvotes: 2

Reeza
Reeza

Reputation: 21264

You need a control program. Assuming you're working on SAS 9.4M5+ you can also use %IF/%THEN in open code.

%INCLUDE will run a program, just need to provide the path.

%let condition= TRUE;

   %if condition == TRUE %then %do;
        %include 'path to sas program.sas';
   %end;

   %include 'path to sas program2.sas';

Upvotes: 1

Related Questions