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 (April 2002, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 11 Apr 2002 14:33:39 -0700
Reply-To:     c-Jeff.Voeller@wcom.com
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Jeff Voeller <c-Jeff.Voeller@WCOM.COM>
Subject:      Re: Matching strings of unequal length
Comments: To: "Carriere, Ron" <rcarriere@MEDNET.UCLA.EDU>
In-Reply-To:  <200204112009.g3BK9EK19654@listserv.cc.uga.edu>
Content-type: text/plain; charset=iso-8859-1

SQL should do it. You can perform your join on the full value of the first file name and the appropriate substring of the second file name.

data work.test1; input file $44.; cards; LAPK.RDSUM.OSHPD.WWH LAPK.DCMMRDRV.CNTLCARD.NPH LAPK.DCMMRDRV.CNTLCARD.SMH LAPK.DCMMRDRV.CNTLCARD.WWH LAPK.RDMSTR.RDTXLRC.SORTIP run;

data work.test2; input file $44.; cards; LAPK.RDSUM.OSHPD.WWH.G0002V00 LAPK.DCMMRDRV.CNTLCARD.NPH.G0008V00 LAPK.DCMMRDRV.CNTLCARD.SMH.SM917E.DATA LAPK.DCMMRDRV.CNTLCARD.WWH.T1018B.G0001V00 LAPK.RDMSTR.RDTXLRC.SORTIP.G0661V00 run;

proc sql; create view work.match as select a.file as FIRSTFILE, b.file as SECONDFILE from work.test1 a, work.test2 b where a.file=substr(b.file,1,length(trim(a.file))); quit;

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU]On Behalf Of Carriere, Ron Sent: Thursday, April 11, 2002 1:09 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: Matching strings of unequal length

Charles writes:

"BY your example given, how would you handle record #3 in 2nd file with the record #3 in 1st file?

This seems to be the real question before an answer can be supplied."

Answer: Yup, that would be a match. I need to match up to the full length of the string in the first table.

Re Jeff's suggestion to match the first four nodes: Unfortunately the full lookup table (file one) is not it is not as regular as the example. It can have 2-6 nodes. And the data in the second file can have any number of extraneous characters after the matching string. A match is a file that matches the string in the first file up to the first blank.

Ron Carriere UCLA Medical Center


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