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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

New Learning Events in April

 

Join us for two new fee-based courses: Administrative Healthcare Data and SAS via Live Web Monday-Thursday, April 24-27 from 1:00 to 4:30 PM ET each day. And Administrative Healthcare Data and SAS: Hands-On Programming Workshop via Live Web on Friday, April 28 from 9:00 AM to 5:00 PM ET.

LEARN MORE

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