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 (November 2011, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 29 Nov 2011 11:57:36 -0800
Reply-To:     Paul Miller <pjmiller_57@YAHOO.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Paul Miller <pjmiller_57@YAHOO.COM>
Subject:      Re: Merge/coding problem using index, find,
              or some other SAS function (with have and need data)
In-Reply-To:  <1322595470.95931.YahooMailClassic@web161602.mail.bf1.yahoo.com>
Content-Type: text/plain; charset=iso-8859-1

Hello Everyone,

Think I found the solution. It looks like I need to use the indexw function as in the code below.

Thanks,

Paul

proc sql; create table test as select * from drugs as d left join names as n on indexw(lowcase(desc), lowcase(names), " /") > 0; quit;

--- On Tue, 11/29/11, Paul Miller <pjmiller_57@yahoo.com> wrote:

> From: Paul Miller <pjmiller_57@yahoo.com> > Subject: Merge/coding problem using index, find, or some other SAS function (with have and need data) > To: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> > Received: Tuesday, November 29, 2011, 1:37 PM > Hello Everyone, > > I have some data about chemotherapy and other medical > procedures in a variable (called "desc") in one of my > datasets. I want to code whether or not each entry in this > variable is chemotherapy using information from a variable > in another dataset (called "names"). > > Often, the lowcase() version of the variables matches and > so linking and coding are easy. In some cases though, the > variable I'm trying to code is a longer string and I need to > determine if the chemotherapy name in the second variable is > somewhere inside it. An added complication is that "desc" > can match more than one value in "names," but I don't want > to wind up with multiple rows for "desc" whenever this is > the case. > > I've provided some sample data below to illustrate what I'm > trying to do. I've been trying to link the rows using proc > sql and the index function but am unable to link properly > for strings like "5FU/Fluorouracil" and "Leucovorin > Calcium." > > Is there some easy way to get the result I need? > > Thanks, > > Paul > > > data drugs; > input desc $ 1-25; > cards; > Venipuncture > Ondansetron > Bevacizumab > Carboplatin > 5FU/Fluorouracil > Leucovorin Calcium > ; > run; > > data names; > input names $ 1-25; > cards; > Bevacizumab > Carboplatin > 5FU > Leucovorin > ; > run; > > data need; > length desc $ 25; > input desc $& chemo $; > cards; > Venipuncture No > Ondansetron No > Bevacizumab Yes > Carboplatin Yes > 5FU/Fluorouracil Yes > Leucovorin Calcium Yes > ; > run; >


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