BookmarkSubscribeRSS Feed
echoli
Obsidian | Level 7

Hi All,

 

Is that possible to use proc template in macro?

I use a proc templat in SAS to combine 6 figures in to one page, that's good. But I have lots of variables, which means I have to run this proc template many times, but I don't want to change every variable name after I run out proc template once.  Someone can give me an  example to run proc template but use macro? I google, but didn't find a good example.

 

Thanks,

C

4 REPLIES 4
Tom
Super User Tom
Super User

I would think that the point of using PROC TEMPLATE would be to eliminate the need for MACRO coding.

What type of template are you creating?

What is it that is varying?

Cynthia_sas
SAS Super FREQ
Hi:
The SAS Macro facility only generates code. So I do not understand your question about using proc template "in macro". Do you mean you want to generate multiple different templates by using a SAS macro program to generate the differing templates. Or, if you are using the Graph Template Language, do you mean you want to use the dynamic MVAR statement to define variables (macro variables) to make the template more flexible?

Please review pages 20/21 of this paper https://support.sas.com/resources/papers/proceedings09/227-2009.pdf and note how the MVAR statement defines the macro variable &WANTY which alters the variable used for the bar chart's Y axis.

The answer to your question really depends on what it is EXACTLY that you need to do and what you mean by having PROC TEMPLATE "in macro".

cynthia
djrisks
Barite | Level 11

Hi, 

 

It's not clear on whether you need to use the NMVAR, MVAR or DYNAMIC statements within GTL, or if you need to use GTL with a SAS MACRO. Can you please show your code, and/or let us know how you are outputting each of these variables?

 

Many thanks,

 

Kriss

Reeza
Super User

It sounds like you're using PROC TEMPLATE incorrectly, but you haven't provided us enough information to tell you where or how to fix it. Really all you've stated is that somethings not working...

 

PROC TEMPLATE supports dynamic variables and should be a 'template' that can be reused so I suspect you're using it incorrectly or not using all the features available. 

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
  • 4 replies
  • 1497 views
  • 1 like
  • 5 in conversation