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 2007, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 16 Apr 2007 05:31:22 -0700
Reply-To:     sbarry@SBBWORKS.COM
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Scott Barry <sbarry@SBBWORKS.COM>
Organization: http://groups.google.com
Subject:      Re: truncate test string?
Comments: To: sas-l@uga.edu
In-Reply-To:  <BAY123-F25779970942FED7537369DE520@phx.gbl>
Content-Type: text/plain; charset="iso-8859-1"

On Apr 16, 6:01 am, tobyd...@HOTMAIL.COM (toby dunn) wrote: > Match = ( VarA =: VArB ) ; > > The colon modifier truncates the longer the two strings to the length of the > shorter and then does the compare between variables. > > Toby Dunn > > You can see a lot by just looking. ~Yogi Berra > > Do not seek to follow in the footsteps of the wise. Seek what they sought. > ~Matsuo Basho > > You never know what is enough, until you know what is more than enough. > ~William Blake, Proverbs of Hell > > From: celia...@GMAIL.COM > Reply-To: celia...@GMAIL.COM > To: S...@LISTSERV.UGA.EDU > Subject: truncate test string? > Date: Sun, 15 Apr 2007 22:17:50 -0700 > > Hi, > > I've got two variable and I want to match them. Then problem is that > variable A is longer than variable B and only the fisrt 6 characters > are the same as that in variable B (if there's a match). > > Question: how can I truncate variable A to match it with B? > > many thanks, > Celia > > _________________________________________________________________ > Get a FREE Web site, company branded e-mail and more from Microsoft Office > Live!http://clk.atdmt.com/MRT/go/mcrssaub0050001411mrt/direct/01/

For the example posed by Toby, the variable Match will yield either a 1 or 0 depending on the expression within the parentheses.

To truncate one SAS variable's value when it matches another, you would need to use SAS functions SUBSTR, INDEX and LENGTH in a DATA step along with your two variables. Give it a try and send back your code to the group for feedback.

Scott Barry SBBWorks, Inc.


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