BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
maroulator
Obsidian | Level 7

I have to run three macros; each defined by extensive pieces of code (filename1, filename2, filename3). Rather than creating one large file with everything (which makes it extremely difficult to debug), I was wandering if I could use the %include statement in a seperate macros to run my other three macros one after the other. I have the following code; could someone with more exprience with the %include statement please provide a sanity check, because this doesn't seem to be running.

%macro MainMacro;

      %include '\filepathmaindirectory\filepathsubdirectory\filename1';

      %include '\filepathmaindirectory\filepathsubdirectory\filename2';

      %include '\filepathmaindirectory\filepathsubdirectory\filename3';

%mend MainMacro;

%MainMacro;

Any suggestions would be helpful.

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Sounds like you are talking about programs and not macros.  If you were talking about macros then your syntax would look more like:

* Define the macro;

%include '\filepathmaindirectory\filepathsubdirectory\filename1';

* Call the macro ;

%filename1(option1=yes,option2=no);

If you create your files in this way then you can use SASAUTOS.

options insert=(sasautos='\filepathmaindirectory\filepathsubdirectory') mrecall ;

%filename1(option1=yes,option2=no);

%filename2;

%filename3;

View solution in original post

3 REPLIES 3
Reeza
Super User

You don't need macros, can use %include directly, though I've always seen it include the .sas extension.

Something like the following should work:

      %include '\filepathmaindirectory\filepathsubdirectory\filename1.sas';

      %include '\filepathmaindirectory\filepathsubdirectory\filename2.sas';

      %include '\filepathmaindirectory\filepathsubdirectory\filename3.sas';

Tom
Super User Tom
Super User

Sounds like you are talking about programs and not macros.  If you were talking about macros then your syntax would look more like:

* Define the macro;

%include '\filepathmaindirectory\filepathsubdirectory\filename1';

* Call the macro ;

%filename1(option1=yes,option2=no);

If you create your files in this way then you can use SASAUTOS.

options insert=(sasautos='\filepathmaindirectory\filepathsubdirectory') mrecall ;

%filename1(option1=yes,option2=no);

%filename2;

%filename3;

Tom
Super User Tom
Super User

You can specify more than one filename in the %INCLUDE statement.

filename myprogs '\filepathmaindirectory\filepathsubdirectory\';

%inc myprogs(filename1 filename2 filename3) / source2;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 835 views
  • 6 likes
  • 3 in conversation