LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (January 2005, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 5 Jan 2005 08:57:38 -0500
Reply-To:     "Richard A. DeVenezia" <radevenz@IX.NETCOM.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Richard A. DeVenezia" <radevenz@IX.NETCOM.COM>
Subject:      Re: SAS equivalent of SQL LIKE

SunStormRider wrote: > In SQL you can do SELECT ... WHERE field1 LIKE "%fred%" > > but what is the equivalent in a data step? >

You probably want to put %fred% inside single quotes. When inside double quotes, the macro system will take a crack at the %fred before the SQL or DATA Step.

If field1 is a column in an input SET, you can use data set option WHERE=

data ...; set myData (where=(field1 like '%fred%'));

If field1 is a column of one or more data sets listed in a merge, you can use the where statement data ....; merge ....; by ....; where field1 like '%fred%'; run;

If field1 is computed during the DATA Step and is to be in an output data set, you can again use the where= data set option

data myData (where=(field1 like '%fred%')); set...; field1 = catx (' ', first, middle, last); run;

-- Richard A. DeVenezia http://www.devenezia.com/


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