BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hello,

Will some one help me out in writing a macro code.
While generating a report in PDF format you normally write a SAS code which includes titles and foot notes also.How do you write a macro code for titles and foot notes exclusively such that when you run the SAS code(which does not include titles and foot notes) along with the macro (which contains the code for titles and footnotes),the combined output should reflect titles and foot notes also.

Thanks.
SAS community member.
3 REPLIES 3
deleted_user
Not applicable
Macros are code generators.
[pre]
%macro common_stuff (something);

title1 "this is the standard top title for &something" ;
title2 "this is the standard subtitle" ;

footnote j=l "Copyright (c) 2008 your company"
j=r "confidential treatment requested"
;
%mend;

....

%macro(Nothing);
proc print uniform data=whatever;
run;
quit;
[/pre]
deleted_user
Not applicable
Thanks for quick response.

I guess the macro which you wrote is suitable for particular table but i am looking for a universal /general macro code which is applicable to any table ( pdf report).


Thanks again.

SAS Community member.
deleted_user
Not applicable
I showed you an example.

From there, you should be able to see, or figure out, what you want to do yourself.

The universal thing to do is not use a macro and just use the title and footnote statements directly themselves. Otherwise, you will just create an overly complicated wrapper that doesn't simplify anything.

Like I just wrote in another thread.

KISS -- keep it simple ...

macro's are meant to simplify and condense/modularize reusable code.

Like %getID and %getPassword(%getID)

Where %getID is

%macro getID;
%lowcase(%sysget(USERNAME))
%mend;

and %getPassword retrieves a user's password from a secure table, which consumes a number of lines of code.

Another way I use a macro is for database access.

I have a macro that has all the pieces to access our MOM data warehouse. I use it in two ways:
1) in an include file that has the following line
[pre]
libname MOM oledb %MOMdb ;
[/pre]

2) to facilitate pass-through SQL
[pre]
proc sql;
connect to oledb as momdb (%momdb) ;

...

disconnect from momdb;
quit;
[/pre]

%momdb returns all of the datasource=, provider=, user=, password=, schema= and prompt=no bits and pieces, providing a single point of maintenance should something have to change.

Now it would be useless for me to write a generic universal %momdb statement for you to use because the bits and pieces would be different. Same goes for a common title and footer thingy.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 3 replies
  • 799 views
  • 0 likes
  • 1 in conversation