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

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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