LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (February 2005, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 7 Feb 2005 21:38:36 +0000
Reply-To:     iw1junk@COMCAST.NET
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Ian Whitlock <iw1junk@COMCAST.NET>
Subject:      Bug in %SCAN (was Re: %substrw)
Comments: cc: LZ <lzhang9830@YAHOO.COM>

Hi Ian, Well-written macro! Two suggestions: Test case 1: %let s1= %selwseq(%str(a, b, c, d), 2, 2, dlim=%str(,)); %put s1=&s1; It returns "b C" instead of "b, c" Test case 2: %let s2 = %selwseq(%str(a, b, max(c,d), d), 2, 2, dlim=%str(,)); %put s2=&s2; It returns "b max(c". I It will be better if the macro can return "b, max(c,d)" LZ <snip> ===================================== LZ,

Thanks. I do not get the problem that you indicate in case 1, when running the Learning Edition 1.3.0.161 under Windows XP.

Fixing the problem that you indicate in case 2 would be hard since %SCAN does not support this sort of thing. Incidentally, in thinking about this response I tried the following.

WARNING: Only the Base product and the SAS/STAT product have been tested for use with VALIDVARNAME=ANY. Other use of this option is considered experimental and may cause undetected errors. 2 OPTIONS VALIDVARNAME=ANY; NOTE: Some of your options or statements may not be supported with the activex or java devices. For further information, please contact Technical Support. 3 OPTIONS DEV=ACTIVEX; 4 ODS LISTING; 5 %put ===========================; =========================== ERROR: Open code statement recursion detected. 6 %put %scan ( a "b c", 2 , %str( )) ; 7 %put ===========================; 8 run; 9 quit; 10

Anyone have any idea where the recursion is coming from? I get the same result in version 9.1.2 with macro quoting by %SUPERQ. Although SCAN works as expected, you cannot cheat and use

%SYSFUNC(SCAN( a "b c", 2 , %str( )))

since it has the same recursion problem. However SCAN in a DATA step works as expected yielding "b.

Ian Whitlock


Back to: Top of message | Previous page | Main SAS-L page