Date: Tue, 5 Aug 2008 16:14:59 -0500
Reply-To: "./ ADD NAME=Data _null_," <iebupdte@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "./ ADD NAME=Data _null_," <iebupdte@GMAIL.COM>
Subject: Re: problem with %INDEX function
Content-Type: text/plain; charset=ISO-8859-1
indexW should be good enough. I don't think you need %IF but regular
old IF instead.
%let x = abc abcdef;
if indexW("&x","abc") > 0 then do; j = 1; end;
On 8/5/08, Zach Peery <email@example.com> wrote:
> I am trying to use the %INDEX function to determine if a character string
> occurs in a macro variable. Seems EZ enough, but it's a little tricky in
> my application. I would like to say that string "abc" occurs in macro
> variable x when x is equal to "abc" or "abc abcdef" but NOT when x is
> equal to "abcdef".
> So the following correctly sets j equal to 1 as written, but I would like
> j to equal to be missing when I use %let x = abcdef (this code still sets
> j = 1 with %let x = abcdef). Please keep in mind that I need to do this
> string search within a macro for reasons I wont go into here. Many thanks!
> %let x = abc abcdef;
> data temp;
> %macro findabc;
> if %index(&x,abc) > 0 then do; j = 1; end;