BookmarkSubscribeRSS Feed
GabOwen
Calcite | Level 5

Hi Guys,

 

I would like to ask for your help to determine if my idea is possible. I am currently automating a group of .sas program and currently finished writing a macro code that creates a table log or statistics that will send and email. Let's call the macro %etl_begin and %etl_end, this macro should be put on pre and post process part. I need to put this %macros in precode and post code of each .sas file without opening and pasting the macro on the code. Any idea how can I do this? Any time my .sas file increments so i'm thinking I would use a x command line to list all the .sas file on a specific folder.

 

 

Thanks.

3 REPLIES 3
Reeza
Super User

.sas files are text files. If your code goes right at beginning and end basic line commands to append the text files should suffice. Look at the command line function called CAT. 

 

https://en.m.wikipedia.org/wiki/Cat_(Unix)

ballardw
Super User

I am not sure if this addresses your situation but if you mean that you want to execute some code before executing another SAS program file perhaps you want a control SAS program that includes the other programs. Then you could place the macro calls before/after the include. The control program would look something like:

 

%etl_begin ;

%include "path/SASProgram1.SAS";

%etl_end;

 

%etl_begin ;

%include "path/SASProgram2.SAS";

%etl_end;

 

%etl_begin ;

%include "path/SASProgram3.SAS";

%etl_end;

 

If you have not used %include all it does is in effect read an external progam file into the current program.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

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
  • 1286 views
  • 0 likes
  • 4 in conversation