Date: Mon, 23 Feb 2004 16:15:11 -0500
Reply-To: Quentin McMullen <quentin_mcmullen@BROWN.EDU>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Quentin McMullen <quentin_mcmullen@BROWN.EDU>
Subject: macro parameter foolishness
Hi All,
Having spent many too many minutes trying to debug a bizarre macro mess I
accidentally made for myself, I thought I would share.
Here is my mess in the form of a puzzle:
%macro me(/*fill me in*/);
%put a=&a;
%mend me;
What can you put into /*fill me in*/ so that the macro call %me(a=1) will
return:
a=
Answer below:
Might have hoped that defining a macro with >1 parameter with the same
name might create an error, or perhaps note? But no, SAS chugs along
happily, with sometimes surprising results:
22523 %macro me(a=,a=);
22524 %put a=&a;
22525 %mend me;
22526
22527 %me(a=1)
a=
Kind Regards,
--Quentin
|