Date: Wed, 29 Dec 2004 15:44:45 -0600
Reply-To: "Dunn, Toby" <Toby.Dunn@TEA.STATE.TX.US>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Dunn, Toby" <Toby.Dunn@TEA.STATE.TX.US>
Subject: Re: Macro parsing question
Content-Type: text/plain; charset="iso-8859-1"
Chang,
I hadn't thought of that, but alas I was only trying to frame out the design so that the poster could hang his specific code onto it. But thanks for the reminder.
So to all you out there don't use tranwrd to take the found phrase out of the list unless you know for certain your list doesn't have multiple occurances of the found word.
Toby
________________________________
From: Chang Y. Chung [mailto:chang_y_chung@HOTMAIL.COM]
Sent: Wed 12/29/2004 3:27 PM
To: Dunn, Toby
Subject: Re: Macro parsing question
On Wed, 29 Dec 2004 15:14:55 -0600, Dunn, Toby <Toby.Dunn@TEA.STATE.TX.US>
wrote:
>Scott,
>
>I am hopeing I read your post correctly:
>
>this hsould do what you want:
>
>%MACRO TEST;
> %LOCAL LIBRARY LIST I TEST;
>%LET LIBRARY = "C:\PROGRAM FILES" "C:\FOO BAR" FOO BAR BLAH
>'C:\BAR FOO';
>
>%LET LIST = LIBRARY;
>%LET I = 0;
>
>%DO %UNTIL (%LENGTH(&LIST) = 0);
>
>%LET I = %EVAL(&I + 1);
>
>%LET TEST = %SYSFUNC(SCANQ(&LIBRARY,&I));
>%PUT &TEST;
>
>%LET LIST = %CMPRES(%SYSFUNC(TRANWRD(&LIST,&TEST, )));
>
>%END;
>
>
>%MEND;
>%TEST
>//
>
>
>On Log:
>"C:\PROGRAM FILES"
>"C:\FOO BAR"
>FOO
>BAR
>BLAH
>'C:\BAR FOO'
>
>HTH
>Toby Dunn
Hi, Toby,
Nice! I should remember that there is the scanq() function in 9!!
By the way, I would not do tranwrd to remove the found word from the list -
- unless this is specifically what you wanted. To see what happens, try
with more than one FOO's.
Cheers,
Chang
|