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.
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;
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';
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;
You can specify more than one filename in the %INCLUDE statement.
filename myprogs '\filepathmaindirectory\filepathsubdirectory\';
%inc myprogs(filename1 filename2 filename3) / source2;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.