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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 659 views
  • 0 likes
  • 4 in conversation