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 (August 2008, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
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
Comments: To: Zach Peery <zpeery@nature.berkeley.edu>
In-Reply-To:  <200808052055.m75Hd10v018430@malibu.cc.uga.edu>
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; data temp; if indexW("&x","abc") > 0 then do; j = 1; end; run; proc print; run;

On 8/5/08, Zach Peery <zpeery@nature.berkeley.edu> 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; > %mend; > %findabc; > run; >


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