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 (November 2002, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 15 Nov 2002 22:55:11 GMT
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>
Organization: EarthLink Inc. -- http://www.EarthLink.net
Subject:      Re: Translate Function with Hex Characters
Content-Type: text/plain;

"Michael S. Zdeb" <msz03@HEALTH.STATE.NY.US> wrote in message news:OF136CCF6B.4DFA431F-ON85256C72.00797D22@health.state.ny.us... > Hi. If I understand the TRANSLATE function correctly, one can list a > series of characters in the TO and FROM arguments. If I use HEX notation > within both TO and FROM, this works.... > > data _null_; > input; > _infile_ = translate(_infile_,"'31'x'31'x","'32'x'33'x"); > put _infile_; > datalines; > 11111222222333333 > ; > run; > > I end up with a string of 1's. If I replace the TO string with non-HEX > characters... > > data _null_; > input; > _infile_ = translate(_infile_,"11","'32'x'33'x"); > put _infile_; > datalines; > 11111222222333333 > ; > run; > > the 2's are replaced with BLANKS, while the 3's are replaced with 1's. > This is the ASCII world (on a PC). Can anyone offer an explanation? > > > Mike Zdeb > New York State Department of Health > ESP Tower - Room 1811 > Albany, NY 12237 > P/518-473-2855 F/630-604-1475

The translate function operates positionally upon the characters in the string values passed to it. Looking vertically on the left of -> you will see the third arg of translate, the second arg appears to the right.

translate(_infile_,"'31'x'31'x","'32'x'33'x") sets up this replacement rule

from character -> to character single quote -> single quote 3 -> 3 2 -> 1

single quote -> single quote x -> x single quote -> single quote 3 -> 3 3 -> 1 single quote -> single quote x -> x

If you want to operate on just two hexadecimally indicated characters you should translate(_infile_,"3131"x,"3233"x)

> _infile_ = translate(_infile_,"11","'32'x'33'x") sets up this replacement rule

single quote -> 1 3 -> 1 2 -> blank

single quote -> blank x -> blank single quote -> blank 3 -> blank 3 -> blank single quote -> blank x -> blank

-- Richard A. DeVenezia http://www.devenezia.com/downloads/sas/macros/#FindFiles Get file information from Windows


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