DATA Step, Macro, Functions and more

Post-processing MPRINT Outputs to Generate Macro-Free Code

Reply
Contributor
Posts: 21

Post-processing MPRINT Outputs to Generate Macro-Free Code

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? 

 

  

Super User
Posts: 5,516

Re: Post-processing MPRINT Outputs to Generate Macro-Free Code

Posted in reply to gabriel_k

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.

Contributor
Posts: 21

Re: Post-processing MPRINT Outputs to Generate Macro-Free Code

Posted in reply to Astounding

How would i write code that is out of Macros ?

Super User
Posts: 5,516

Re: Post-processing MPRINT Outputs to Generate Macro-Free Code

Posted in reply to gabriel_k

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.

Contributor
Posts: 21

Re: Post-processing MPRINT Outputs to Generate Macro-Free Code

Posted in reply to Astounding

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 ?

PROC Star
Posts: 1,324

Re: Post-processing MPRINT Outputs to Generate Macro-Free Code

Posted in reply to gabriel_k

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.

Super User
Posts: 5,516

Re: Post-processing MPRINT Outputs to Generate Macro-Free Code

Posted in reply to gabriel_k

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.

Ask a Question
Discussion stats
  • 6 replies
  • 300 views
  • 4 likes
  • 3 in conversation