BookmarkSubscribeRSS Feed
gabriel_k
Obsidian | Level 7

Hello, 

 

I have a large project with lots of macros and included programs (SAS 9.3 on WIN server via EG 7.1 32-bit). The idea is to produce executable code in external .sas files after the project execution.

 

I have found this article and would like to do exactly they are doing: 

http://www.lexjansen.com/pharmasug/2002/proceed/TechTech/tt14.pdf

 

Could someone post the code transforming MPRINT Outputs to executable code? 

 

  

6 REPLIES 6
Astounding
PROC Star

While someone took the time to write a paper and a macro about this, you really only need a small change.

 

options mprint;

filename mprint 'path to some file to hold the SAS code';

 

Run your macro-based code, and take a look at the file that you define in the FILENAME statement.  You'll see all the SAS code is there.  Although it is not pretty, it's the code you are asking for.

gabriel_k
Obsidian | Level 7

How would i write code that is out of Macros ?

Astounding
PROC Star

You don't.  You just run the code that includes and utilizes the macros.  At the end of that, any code that was generated by the macros will magically appear in the file that you have defined in the FILENAME statement.

 

Note that this does NOT include code that is not macro-generated.  So if there is a mix of macro and non-macro code, you will still need to integrate the macro-generated code with the non-macro-generated code.

gabriel_k
Obsidian | Level 7

My question actually is about how to intagrate this all and not about the magic of MPRINT option, not to say more. Specificaly when thete is 50000 lines of code and lots of marco variables out of macros ?

Quentin
Super User

I think your question would be clearer if you could give an example.  You don't need to show 500,000 lines of code.  But make an example of the the sort of code you have as a starting points, and then show what your would like to get as output from post-processing the code.

The Boston Area SAS Users Group is hosting free webinars!
Next webinar will be in January 2025. Until then, check out our archives: https://www.basug.org/videos. And be sure to subscribe to our our email list.
Astounding
PROC Star

There's no easy road to integrating here.  You have three sources of code:

 

(1) SAS code that is part of the program

(2) SAS code that is in a file, brought in by %include

(3) SAS code that is generated by running macros

 

MFILE / MPRINT provides the third source, the SAS code that was generated by running macros.  But you still have to roll up your sleeves and combine all three sources in the right order.  Presumably, this client is paying you for your time to do this.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of 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
  • 6 replies
  • 1475 views
  • 4 likes
  • 3 in conversation