%include

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 121
Accepted Solution

%include

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.


Accepted Solutions
Solution
‎07-18-2014 11:34 AM
Super User
Super User
Posts: 6,500

Re: %include

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


All Replies
Super User
Posts: 17,828

Re: %include

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';

Solution
‎07-18-2014 11:34 AM
Super User
Super User
Posts: 6,500

Re: %include

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;

Super User
Super User
Posts: 6,500

Re: %include

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

filename myprogs '\filepathmaindirectory\filepathsubdirectory\';

%inc myprogs(filename1 filename2 filename3) / source2;

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

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