BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
fastandcurious
Obsidian | Level 7

Hello,

I am learning proc template and wanted to apply different text headers, to different table headers, in for Proc Freq/other procedures (if that's possible). I've seen macros for templates, but I can't recall if there were any macros used to apply custom table headers.

 

Example of what I'm looking for:

This code gives the title for the following table:

fastandcurious_0-1691776337816.pngfastandcurious_1-1691776398841.png

 

The example I saw uses the following statement, to apply the template:

 file=print ods=template="Classroom");

put_ods_;

run;

 

I understand proc template controls the style for ods, so I've been using a template that's suitable for all the tables, but it would be nice to put the "titles" in the headers for each table instead.

 

 

Thank you!

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Possibly the "easiest" is to use MVAR statement and a macro variable.

You would add an MVAR statement with the list of macro variables to be used

 

Mvar titletext ;

before the headers.

In the header you want use that variable in the Text statement.

Very basic:

text titletext;

You would place any other fixed text in quotes before and/or after the macro variable. So suppose you had a class subject title that wanted to read as "Class scores for Algebra".

you might, after defining the Subject in Mvar use

text "Class scores for "  subject;

Prior to actual USE of the template you would have to define the Macro variable.

%let titletext= Classroom BMI Information;
%let subject= Algebra;

DYNAMIC is similar to MVAR but links to the value of either data step variable or something a Procedure generates (though finding those may be fun)

 

NMVAR is similar to MVAR but attempts to convert the value to an actual numeric value so could be used in a calculation.

View solution in original post

2 REPLIES 2
ballardw
Super User

Possibly the "easiest" is to use MVAR statement and a macro variable.

You would add an MVAR statement with the list of macro variables to be used

 

Mvar titletext ;

before the headers.

In the header you want use that variable in the Text statement.

Very basic:

text titletext;

You would place any other fixed text in quotes before and/or after the macro variable. So suppose you had a class subject title that wanted to read as "Class scores for Algebra".

you might, after defining the Subject in Mvar use

text "Class scores for "  subject;

Prior to actual USE of the template you would have to define the Macro variable.

%let titletext= Classroom BMI Information;
%let subject= Algebra;

DYNAMIC is similar to MVAR but links to the value of either data step variable or something a Procedure generates (though finding those may be fun)

 

NMVAR is similar to MVAR but attempts to convert the value to an actual numeric value so could be used in a calculation.

fastandcurious
Obsidian | Level 7
Thank for this, I'm going to give it a try and share the output when I get the chance.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 277 views
  • 1 like
  • 2 in conversation