Date: Tue, 22 Jan 2002 11:27:51 -0500
Reply-To: Ian Whitlock <WHITLOI1@WESTAT.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Ian Whitlock <WHITLOI1@WESTAT.COM>
Subject: Re: strange behaviour with %NRBQUOTE
Content-Type: text/plain; charset="iso-8859-1"
Jim,
It looks like Bob's advice is good from this little test.
data w ;
x = 1 ;
label x = 'a&b, or %c with ''tough stuff'' and ^= "more" problems' ;
call symput ( "xlab" , vlabel(x) ) ;
run ;
%let vlabel = %superq(xlab) ;
%put %eval(&vlabel^=%str()) ;
%put vlabel=&vlabel ;
%let newval = %qsysfunc(tranwrd(&vlabel,%str(%'),%str(%'%'))) + ok ;
%let newval = %superq ( newval ) ;
proc datasets lib = work ;
modify w ;
label x = %unquote(%str(%')&newval%str(%')) ;
run;
quit ;
proc contents data = w ;
run ;
If not you had better show a label that presents problems.
IanWhitlock@westat.com
-----Original Message-----
From: Robert Virgile [mailto:virgile@MEDIAONE.NET]
Sent: Tuesday, January 22, 2002 10:49 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: strange behaviour with %NRBQUOTE
Jim,
The message suggests that %nrbquote is not necessarily quoting all the
characters it should in a timely fashion. Have you tried:
%let varlabel = %superq(varlabel);
If this works, I'm sure we'd all like to know.
Good luck.
Bob V.
-----Original Message-----
From: Jim Groeneveld <J.Groeneveld@ITGROUPS.COM>
Newsgroups: bit.listserv.sas-l
To: SAS-L@LISTSERV.UGA.EDU <SAS-L@LISTSERV.UGA.EDU>
Date: Tuesday, January 22, 2002 10:31 AM
Subject: strange behaviour with %NRBQUOTE
>Hallo all,
>
>I'm back on the list after a rather long time. Let me jump back in with a
>rather
>complicated problem. It concerns the use of the macro function %NRBQUOTE.
>
>I developed a (complicated) program using several (complicated) macros, one
>of
>which a.o. processes (i.e. changes) the contents of arbitrary variable
>labels.
>By itself this is not the problem, but as variable labels may have quite a
>lot
>of characters, which have (or may have) specific meanings within a macro
>(like
>&, %, etc.), a macro variable (e.g. &VarLabel), containing the contents of
a
>
>variable label must be referenced using the %NRBQUOTE macro function in
>order to
>avoid the unwanted interpretation of any character within the label, e.g.
>%NRBQUOTE(&VarLabel). Doing so works fine and without problems.
>
>Now, instead of applying the function NRBQUOTE each time where the
&VarLabel
>is
>being referenced, I looked for a shorter, more elegant solution by defining
>the
>macro variable &VarLabel once as its uninterpreted NRBQUOTEd result: %LET
>VarLabel = %NRBQUOTE (&VarLabel); and referencing it further without
>specifying
>the macro function each time, thus just by specifying &VarLabel. A test
>program
>(see below) has shown this to work all right. However, it appeares that
>applying my program, processing datasets, with the adapted macro it eats
>disk
>space indefinitely, until disk space has been used completely and the
>program
>halts, without having produced the desired output. Viewing the work
>directory
>(in another window) does not show some internal scratch file to grow
>indefinitely, neither some file of size 0 which may be open and filled, it
>only
>shows decreasing free disk space. The log file reports repeately:
>ERROR: Maximum level of nesting of macro functions exceeded.
>
>This is quite a surprise to me and I cannot give a simplified and
>straightforward example showing the phenomenon. I can only ask for some
>general
>hints as to what I may be doing wrong or what SAS is doing using such a
>construct. I have added the test program, which runs fine, below and the
>output
>of DOS' FC (file compare) as well, that shows the only differences between
>the
>original macro and the adapted one. Of course I can live with the original,
>correctly working construct, but I would like to know why the adapted
>construct
>behaves as it does. I am still using SAS 6.12.
>
>TIA.
>
>Regards - Jim.
>--
>Y. (Jim) Groeneveld, MSc IMRO TRAMARKO tel. +31 412 407 070
>senior statistician, P.O. Box 1 fax. +31 412 407 080
>senior data manager 5350 AA BERGHEM IMRO TRAMARKO: a CRO
>J.Groeneveld@ITGroups.com the Netherlands in clinical research
>
>My computer has no idea what I am doing; sometimes the reverse also
applies.
>
>Notice of confidentiality: this e-mail may contain confidential information
>intended for the addressed recipient only.
>If you have received this e-mail in error please delete this e-mail and
>please notify the sender so that proper delivery
>can be arranged.
|