Esteemed Advisers:
I developed 6 SAS programs using SAS Studio that I execute sequentially to achieve the desired result. I would like to combine these six into a single code. Do I have to copy/paste all six into a single code or is it possible to somehow "call" them sequentially, as if they were stand-alone subroutines?
Thanks in advance for your help,
Gene
Short smart-Alec answer: Yes
Details as to what the code looks like may be needed. Depending on what you are actually doing it may be possible to combine data step code into one data step. Maybe.
The %include statement will bring code from an external SAS file. Dummy example:
%include "c:\somefolder\mysasprog1.sas";
would call the code in the Mysasprog1 program file when encountered. There are other ways to use %include to reference the file but this is the basic approach. Make sure that any path starts at a drive or disk mount that is seen by the system running SAS which can get tricky with server versions.
As will anything related to computers there are restrictions such as %include follows a completed statement (i.e. ends with ; ) and NOT following a Cards or Datalines statement directly.
Calling specific code as desired might be macro coding where you compile a macro and then use the code where needed if it may execute in different order sometimes.
Short smart-Alec answer: Yes
Details as to what the code looks like may be needed. Depending on what you are actually doing it may be possible to combine data step code into one data step. Maybe.
The %include statement will bring code from an external SAS file. Dummy example:
%include "c:\somefolder\mysasprog1.sas";
would call the code in the Mysasprog1 program file when encountered. There are other ways to use %include to reference the file but this is the basic approach. Make sure that any path starts at a drive or disk mount that is seen by the system running SAS which can get tricky with server versions.
As will anything related to computers there are restrictions such as %include follows a completed statement (i.e. ends with ; ) and NOT following a Cards or Datalines statement directly.
Calling specific code as desired might be macro coding where you compile a macro and then use the code where needed if it may execute in different order sometimes.
Yes, you can create what I call a "batch file" even though it is SAS code. Example:
%include "full_path_to_file1.sas";
%include "full_path_to_file2.sas";
...
%include "full_path_to_file6.sas";
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.