Date: Wed, 13 May 2009 15:59:07 -0400
Reply-To: Chang Chung <chang_y_chung@HOTMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Chang Chung <chang_y_chung@HOTMAIL.COM>
Subject: Re: Macro quoting again !
On Wed, 13 May 2009 13:52:29 -0400, Ya Huang <ya.huang@AMYLIN.COM> wrote:
>Hi there,
>
>Macro a with a get the result as expected. But macro b
>is not, why is that?
>
>Thanks
>
>Ya
>
>1 %macro a(tit=);
>2 %put &tit;
>3 %mend;
>4
>5 %a(tit=%str(Change %(%%%)));
>Change (%)
>6
>7 %macro b(mlst=);
>8 %unquote(&mlst);
>9 %mend;
>10
>11 %b(mlst=%nrstr(
>12 %a(tit=%str(Change %(%%%)))
>13 ));
Hi, Ya,
The following works. you don't need to mask parens with a percent sign when
the parentheses are balanced. But since the inner most text string quoted
by %str is processed twice(once by &mlst and another by &tit), you need to
double up the percent sign. You can also get rid of some unnecessary semi-
colons. hth.
Cheers,
Chang
%macro a(tit=);
%put &tit;
%mend a;
%macro b(mlst=);
%unquote(&mlst)
%mend b;
%b(mlst=%nrstr(
%a(tit=%str(Change (%%%%)))
))
/* on log
Change (%)
*/
|