LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (August 2006, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Tue, 29 Aug 2006 16:53:58 -0400
Reply-To:   Ya Huang <ya.huang@AMYLIN.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Ya Huang <ya.huang@AMYLIN.COM>
Subject:   Macro parameter to accept either var name or literal value ?

Hi there,

Is it possible for a macro parameter to accept a variable name if that variable already exists, or if not, use it as the value to assign to another variable?

%macro name(newname=); data class; set sashelp.class (obs=2 keep=name); newname=&newname; run;

proc print; run; %mend;

%name(newname=name);

Obs Name newname

1 Alfred Alfred 2 Alice Alice

%name(newname=Clinton);

Obs Name newname Clinton

1 Alfred . . 2 Alice . .

I want it as

Obs Name newname

1 Alfred Clinton 2 Alice Clinton

This seems to be a very common trick in macro programming, just can't find an example how it is implemented.

Thanks

Ya


Back to: Top of message | Previous page | Main SAS-L page