Date: Thu, 21 Oct 2010 12:59:43 -0700
Reply-To: "Terjeson, Mark" <Mterjeson@RUSSELL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Terjeson, Mark" <Mterjeson@RUSSELL.COM>
Subject: Re: Macro quoting help
In-Reply-To: A<AANLkTi=47kLdb=3TNYF8ujvL3k7F+e7p45pV=y1Q_PGV@mail.gmail.com>
Content-Type: text/plain; charset="us-ascii"
Hi Yu,
Usually if you get too many quoting
functions and it is still not working
it is usually best to scale back down
and just find the timing instead of
trying to brute-force with functions.
Also, the arg to %summary is what needs
to be not-resolved so moved nr inside
%summary instead of outside. It is
mainly the apostrophe in the arg that
is causing the issues so to hold one
layer back for timing sake the apostrophe
is swapped out with %' so as to skip the
first layer of resolution. The % is an
escape character to tell the parser to
ignore the ' for at least one pass.
Try this:
data event_id;
hospital_name="some name's Hospital";
output;
run;
%macro summary(hospital_name);
data test;
name="&Hospital_name";
output;
run;
%mend;
data _null_;
set event_id;
str='%summary(%nrstr('||tranwrd(hospital_name,"'",'%'||"'")||'))';
put str=;
call execute (Str);
run;
Hope this is helpful,
Mark Terjeson
Investment Business Intelligence
Investment Management & Research
Russell Investments
206-505-2367
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Yu
Zhang
Sent: Thursday, October 21, 2010 12:11 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Macro quoting help
Hi,
I want to pass a name to the macro. the macro fails to run when there is
an
apostrophe in the name. for example,Jame's. the parameters that need to
pass to the macro are stored in a SAS dataset. Call execute routine will
be
used to generate the Macro call.
for some reason, I need to delay the macro execution. here is my code.
it
seems it is not possible to accomplish what I want. if the %nrstr was
not
used, the code will run with no problem. However, I really want to the
delay
the macro execution. what I would like to see in the log are
Note: Call execute generated line.
+%summary (xxxx)
execution of the macro
Note: Call execute generated line.
+%summary(yyyy)
execution of the macro
Note: Call execute generated line.
+%summary(zzzz)
.......
Warning: the code might crash your machine, please run it in a new SAS
session.
Can someone help?
Thanks!
Yu
data event_id;
hospital_name="some name's Hospital";
output;
run;
%macro summary(hospital_name);
data test;
name="&Hospital_name";
output;
run;
%mend;
data _null_;
set event_id;
str='%nrstr(%summary(%bquote('||hospital_name||')))'; <-------------need
some help??
call execute (Str);
run;