Date: Sun, 30 Aug 2009 18:47:54 -0400
Reply-To: Ian Whitlock <iw1sas@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Ian Whitlock <iw1sas@GMAIL.COM>
Subject: Re: Macro quoting for &
Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes
Summary: Remarks about SCAN or %SCAN
#iw-value=1
Kevin,
I note that others have helped you with the quoting part of your
problem,
but it is unclear if you realize how the functions work.
The third argument is a list of delimiters. You have listed " twice and
/ four times. The chances are that you do not want " as a delimiter,
particularly because you mention a list of folder names and " is used by
Windows to indicate the characters of a folder name, e.g. "x y" is a
folder
name that has a space in it.
Now the fact that you go out of the way to write //// suggests that
you think
%scan (a/b////c,2,"////")
is c. It is not it is b.
Now what about
%scan (a/b////c,3,"////")
Here the value is c because consecutive delimiters are ignored. It is
curious that
all the documentation prior to 9.2 did not find it necessary to spell
out this
behavior. The documentation for 9.2 got very much better, possibly
because a fourth
parameter was added which could change this behavior.
However, I did not see anything to allow a single delimiter consisting
of multiple
characters. If you really need this feature you could write a macro
function
using %INDEX and %SUBSTR to locate and extract the delimited names.
Ian Whitlock
=================
Date: Fri, 28 Aug 2009 14:09:24 -0400
From: Kevin Viel <citam.sasl@GMAIL.COM>
Subject: Macro quoting for &
This is a simplification of a macro I have written, without any attempts
to use appropriate quoting. I would appreciate suggestions about the
right macro functions. The ampersand is contained within a folder
name on
Windows and the macro variable containing it will be used in system
commands using the X statement and Call Execute().
75 %macro qtest ( list = ) ;
76
77 %let i = 1 ;
78 %let value = %scan( &list. , &i. , "////" ) ;
79
80 %do %while ( &value ne ) ;
81
82 %put &value ;
83
84 %let i = %eval( &i. + 1 ) ;
85 %let value = %scan( &list. , &i. , "////" ) ;
86 %end ;
87
88
89
90
91 %mend qtest ;
92
93 options Nomlogic ;
94 %qtest ( list = 1&A////Old )
WARNING: Apparent symbolic reference A not resolved.
WARNING: Apparent symbolic reference A not resolved.
WARNING: Apparent symbolic reference A not resolved.
WARNING: Apparent symbolic reference A not resolved.
WARNING: Apparent symbolic reference A not resolved.
1&A
WARNING: Apparent symbolic reference A not resolved.
Old
WARNING: Apparent symbolic reference A not resolved.