Date: Thu, 7 May 1998 18:00:52 GMT
Reply-To: Adam Hendricks <adam@BCSFSE.CA.BOEING.COM>
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: Adam Hendricks <adam@BCSFSE.CA.BOEING.COM>
Organization: SRP II Team
Subject: Re: %str() vs. %nrstr()
Content-Type: text/plain; charset=us-ascii
> Does anyone know whether using %nrstr(), when you are sure that there is
> no macro resolving to be done inside the brackets, is more efficient
> than using %str()?
> I often see %str() in code when it is clear that there is no macro
> resolution needed and it seems to me that you can avoid having the macro
> processor scan the function argument if you use %nrstr().
> Does this sound right or is there some complication that I'm missing?
> Stewart Ravenhall
> mailto: firstname.lastname@example.org
> The opinions expressed in this communication are my own,
> and do not necessarily reflect those of my employer.
%nrstr and %str will resolve %' %" %( %) to ' " ( ). But %nrstr will
not resolve macros or macrovariables whereas %str will. 100,000 loops
through the %nrstr call below took 14 seconds of CPU time compared to 45
seconds for 100,000 loops through the %str call on our HP 460 w/
HP-UX 10.02. The difference occurs because %str resolves %test1 and
&test2 defined in the code below. Running the same test on both %str
and %nrstr without resolving %test1 and &test2 (i.e. resolving
%' %" %( %) only) yielded similar CPU times around 11.5 seconds. So it
is safe to conclude that both are equivilantly efficient within thier
intersection of equal functionality (i.e. resolving %' %" %( %) only).
%let test2 = Here;
%put nrstr: %nrstr(%test1 , = ; %' %" %( %) &test2);
%put str: %str(%test1 , = ; %' %" %( %) &test2);
Prints to Log:
str: Two words , = ; ' " ( ) Here
nrstr: %test1 , = ; ' " ( ) &test2
\ | Adam Hendricks TAD Staffing (assigned to SRP) | /
\ | 425-234-6108 email@example.com | /
\ | http://www.aa.net/ahendrix | /
/ | | \
/ |________________________________________________| \