DATA Step, Macro, Functions and more

writing macro code

Reply
N/A
Posts: 0

writing macro code

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.
N/A
Posts: 0

Re: writing macro code

Posted in reply to deleted_user
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]
N/A
Posts: 0

Re: writing macro code

Posted in reply to deleted_user
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.
N/A
Posts: 0

Re: writing macro code

Posted in reply to deleted_user
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.
Ask a Question
Discussion stats
  • 3 replies
  • 163 views
  • 0 likes
  • 1 in conversation