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.

BASUG is hosting free webinars Next up: Mike Sale presenting Data Warehousing with SAS April 10 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
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-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
  • 6 replies
  • 1164 views
  • 4 likes
  • 3 in conversation