reusable macros

Reply
N/A
Posts: 0

reusable macros

where exactly macros are reused please give me example
SAS Super FREQ
Posts: 8,721

Re: reusable macros

Here's an example of DEFINING a macro program:
[pre]
options mprint mlogic symbolgen;

%macro prtds(dsn=, limit=10);
proc print data=&dsn (obs=&limit);
title "Print of &limit rows in &dsn";
run;
%mend prtds;

** now look in WORK.SASMACR catalog for the session compiled macro;
[/pre]

Here's how the macro program would be reused:
[pre]
** then reuse the %PRTDS macro program;

%prtds(dsn=sashelp.class, limit=5);
run;

%prtds(dsn=sashelp.prdsale, limit=20);
run;

%prtds(dsn=sashelp.shoes, limit=2);
run;

[/pre]

This book is a good resource
SAS Programming in the Pharmaceutical Industry by Jack Shostak

Also, you can go to Google and type this search string into the Google Search box:
Macro site:www.lexjansen.com/pharmasug

The resulting hits will be of invaluable help. Of course, referring to the SAS Macro facility documentation will help answer your macro questions, too.

cynthia
N/A
Posts: 0

Re: reusable macros

one question:

what's 'dsn' mean here?

i always use 'table', 'tbl', not the standard syntax in SAS Smiley Happy thanks!


-- read SAS Programming I, II, very resourceful for SAS beginners. Message was edited by: David@CRO
SAS Super FREQ
Posts: 8,721

Re: reusable macros

In my examples, LIB generally stands for SAS libname and DSN generally stands for Data Set Name. A SAS dataset is the equivalent of what you call a TABLE.

As far as jargon...I like this example from the Programming I course which shows how the various terms relate to each other (from the different "ages" of Data Processing):
[pre]
"mainframe" SAS Relational DB
term term or SQL term
file data set table
record observation row
field variable col
[/pre]

cynthia
N/A
Posts: 0

Re: reusable macros

Thank you very much, Cynthia!

I know LIB/LIBNAME, but I alway read DSN, and no idea what's that mean Smiley Wink

I like explanation in SAS Prog1, good example for newbies and those moving from other domain.
Ask a Question
Discussion stats
  • 4 replies
  • 440 views
  • 0 likes
  • 2 in conversation