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

Hi. 

 

I have multiple programs (10) in a folder.  They are lengthy.   Is there a SAS script that can allow me to write string of code to tell SAS to run all Programs within that folder?   Thank you. Example: My SAS programs and original table files  D:\Data_Trending

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

I've merged your posts into one, please do not post the same question multiple times. 

 

You can use %INCLUDE with a wild card to call all programs but they may not run in the order you want. 

 

%include 'D:\Data_Trending\*.sas' / source2 lrecl=500;

SOURCE2 tells SAS to still put the code to the log and LRECL specifies the line length of the input program, the default is 256 I believe which can sometimes truncate your code causing issues. 

 


@BaileyY wrote:

Hi. 

 

I have multiple programs (10) in a folder.  They are lengthy.   Is there a SAS script that can allow me to write string of code to tell SAS to run all Programs within that folder?   Thank you. Example: My SAS programs and original table files  D:\Data_Trending

 


 

View solution in original post

5 REPLIES 5
BaileyY
Obsidian | Level 7
 

Hi. 

 

I have multiple programs (10) in a folder.  They are lengthy.   Is there a SAS script that can allow me to write string of code to tell SAS to run all Programs within that folder?   Thank you. Example: My SAS programs and original table files  D:\Data_Trending

 

Cynthia_sas
SAS Super FREQ
Hi:
You already posted this question in the SAS Programming forum, here: https://communities.sas.com/t5/SAS-Programming/Auto-run-SAS-Programs/m-p/599648#M173127 and that is probably a better place for the question than the Procedures forum.
Cynthia
Reeza
Super User

I've merged your posts into one, please do not post the same question multiple times. 

 

You can use %INCLUDE with a wild card to call all programs but they may not run in the order you want. 

 

%include 'D:\Data_Trending\*.sas' / source2 lrecl=500;

SOURCE2 tells SAS to still put the code to the log and LRECL specifies the line length of the input program, the default is 256 I believe which can sometimes truncate your code causing issues. 

 


@BaileyY wrote:

Hi. 

 

I have multiple programs (10) in a folder.  They are lengthy.   Is there a SAS script that can allow me to write string of code to tell SAS to run all Programs within that folder?   Thank you. Example: My SAS programs and original table files  D:\Data_Trending

 


 

BaileyY
Obsidian | Level 7
Thank you so much!! You are my favorite for responses. I am not an expert SAS programmer and some of the existing code on this forum can be difficult to understand and translate. You always provide exceptional explanation with your help. So appreciate you on this forum! Thank you!
VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

Hello @BaileyY a quick searched reveals many solution to your question.

here is one possible solution.

 

%macro run_one (path);
   proc printto log="&path.log";
   run;
   proc printto print="&path.lst";
   run;
   %include "&path.sas";
   run;
%mend run_one;

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
  • 5 replies
  • 2177 views
  • 3 likes
  • 4 in conversation