BookmarkSubscribeRSS Feed
deleted_user
Not applicable
where exactly macros are reused please give me example
4 REPLIES 4
Cynthia_sas
SAS Super FREQ
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
deleted_user
Not applicable
one question:

what's 'dsn' mean here?

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


-- read SAS Programming I, II, very resourceful for SAS beginners. Message was edited by: David@CRO
Cynthia_sas
SAS Super FREQ
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
deleted_user
Not applicable
Thank you very much, Cynthia!

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

I like explanation in SAS Prog1, good example for newbies and those moving from other domain.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Health and Life Sciences Learning

 

Need courses to help you with SAS Life Sciences Analytics Framework, SAS Health Cohort Builder, or other topics? Check out the Health and Life Sciences learning path for all of the offerings.

LEARN MORE

Discussion stats
  • 4 replies
  • 1332 views
  • 0 likes
  • 2 in conversation