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

Hello,

 

I am curious what the best way is to print the source code to the log for an auto call macro program during that programs execution.

 

Can I include a data null step to read in the .sas program while that macro is being ran?  Or would this cause an issue?  Such as:

 

%MACRO client_name ;

DATA _NULL_ ;
    INFILE "\\shared_drive\user_group\projects\client_programs\client_name\client_name.sas" ;
    INPUT ;
    PUT _INFILE_ ;
RUN ;


DATA work.import_data ;
    INFILE "&file_path.\&client_name.\raw_data_file.txt" TRUNCOVER ;
    INPUT
        @1    account    $10.
        @11   name       $30. ;
RUN ;


PROC PRINT DATA=work.import_data ;
RUN ;

%MEND client_name ;

I have not been able to find a way to print autocall macro code to the log, like you can with stored compiled macros using %copy.

 

Any help would be appreciated.  Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
LeonidBatkhan
Lapis Lazuli | Level 10

Hi GBL__,

 

SOURCE2 System Option specifies whether SAS writes secondary source statements from included files to the SAS log.

SOURCE2 writes source statements from files that have been included by %INCLUDE statements or autocall macros to the SAS log.

So your solution is to place the following statement before your macro call:

options source2;

No need to read and write.

 

View solution in original post

2 REPLIES 2
LeonidBatkhan
Lapis Lazuli | Level 10

Hi GBL__,

 

SOURCE2 System Option specifies whether SAS writes secondary source statements from included files to the SAS log.

SOURCE2 writes source statements from files that have been included by %INCLUDE statements or autocall macros to the SAS log.

So your solution is to place the following statement before your macro call:

options source2;

No need to read and write.

 

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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
  • 2 replies
  • 1046 views
  • 0 likes
  • 2 in conversation