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 (August 2001, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Thu, 2 Aug 2001 23:43:43 -0700
Reply-To:   Dirk M <dirk.mesotten@EMSTAXIPOST.BE>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Dirk M <dirk.mesotten@EMSTAXIPOST.BE>
Organization:   http://groups.google.com/
Subject:   Re: Reading a txt-file with 'squares' (hexadecimal values)
Content-Type:   text/plain; charset=ISO-8859-1

Hi,

All useful codes in themselves, but they didn't solve my problem yet, I've got a txt-file with a square in the var 'name' that always stop reading, try the code below for an exemple:

data _null_; file baddata; put 'GARCIA'; put 'OTT P.'; put 'VAN LAETHEM'; put 'VAN POUCKE'; put 'LIEVENS'; put 'ABRARAY'; run; data a; infile baddata dlm =','; input @; _infile_=left(compbl(translate(_infile_,' ','000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F'x))); informat name $10.; input name;

run; proc print;run;

Regards Dirk

Nathaniel_Wooding@DOM.COM (Nat Wooding) wrote in message news:<85256A9B.0041ECE3.00@smtpmta.vapower.com>... > Koen > > This is a useful snippit. I just tried it in 8.1 and it works. I then tried to > see what you could do with/to the _infile_ and it seems that you may beat up on > it prior to reading it as real data. The following is a modification of your > code that fixes the non-printing characters in place. > > ****************************************** > filename baddata 'c:\park\baddata.txt'; > data _null_; > file baddata; > put 'a,b,c,' '01'x ',d'; > > put 'a,b,c,' '01'x ',d'; > put 'a,b,c,' '01'x ',d'; > run; > data a; > infile baddata dlm =','; > input @; > _infile_=left(compbl(translate(_infile_,' > ','000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F'x))); > informat a b c c1 d $1.; > input a b c c1 d; > > run; > proc print;run; > > > > > > > > > "Vyverman, Koen" <koen.vyverman@FID-INTL.COM> on 08/01/2001 07:33:05 AM > > Please respond to "Vyverman, Koen" <koen.vyverman@FID-INTL.COM> > > > To: SAS-L@LISTSERV.UGA.EDU > cc: (bcc: Nathaniel Wooding/IN/FH/VANCPOWER) > > > Subject: Re: Reading a txt-file with 'squares' (hexadecimal values) > > > > Dirk inquired: > > > I want to read a txt-file into SAS, but the txt-file I receive > > sometimes contains 'squares', i.e. hexadecimal values. When SAS > > encounters such a value it stops reading the txt-file. > > I frequently perform initial cleaning up of inbound alphanumeric > strings by removing undesirable characters. The following snippet > of code e.g. will erase all non-printing characters with a hex- > value between '00' and '1F' from an incoming string. > > filename txt 'c:\word files saved as text\blah.txt'; > > data begone; > length string $ 5000; > infile txt lrecl=5000; > input; > string=left(compbl(translate(_infile_,' > ','000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F'x))); > if string ne ' ' then output; > run; > > This works in SASv8.2 on WinNT (SP 6). I seem to remember that the > ability to use _infile_ just like any character variable was only > introduced recently, so this may not work as such in older versions > of the System ... > > Kind Regards, > Koen. > > --------------------------------- > Koen Vyverman > Database Marketing Manager > Fidelity Investments - Luxembourg > ---------------------------------


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