DATA Step, Macro, Functions and more

Passing parameters to a sas macro

Occasional Contributor
Posts: 8

Passing parameters to a sas macro

I'm trying to create a main SAS program that will run different SAS programs if the criteria fits.


For example 

if this condition then do;

%include "sas programs\myfolder\" ; run;


%include "sas programs\myfolder\; run;


How can I pass parameters to these programs?

Super User
Posts: 13,297

Re: Passing parameters to a sas macro

What is in the program files? Is anything set up to accept parameters? What types of values need to be set as parameters?


As much as  practical the best way is to place values in data sets in a library other than WORK. Reasons here are so you have the data sets in case of a crash (a very common problem when learning macro coding). Another is that values in a data set can be used with CALL Execute and may obviate the need for separate macros as call execute also builds SAS code statements.


Or do you mean that those scripts have macro definitions that you want to use? If that is the case then %include the files before use so they are available (or investigate SAS Autocall library in documentation). Then add statements to use the macros.


Details missing so pretty generic response.

Occasional Contributor
Posts: 8

Re: Passing parameters to a sas macro

I figured it out thank for your help

Ask a Question
Discussion stats
  • 2 replies
  • 2 in conversation