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 (September 2002, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 10 Sep 2002 16:38:15 +0100
Reply-To:     Peter Crawford <peter.crawford@DB.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Peter Crawford <peter.crawford@DB.COM>
Subject:      Re: reading raw data
Comments: cc: Talbot Katz <TopKatz@MSN.COM>
Content-type: text/plain; charset=iso-8859-1

You don't need any programs for this ! To examine raw data, try the command string (in the sas display manager) fslist 'your file' ; cols; nums; hex

It is good for up to 32K bytes wide, has 5digit line number column (you just get ***** when there are too many llines) It is *great* for a quick view !

I place the "cols; nums; hex" on a function key for fslist. reducing typing of the command string to fsl 'my file' ( fsl is an abbreviation for fslist, acceptable in most sas windows)

Datum: 09/09/2002 23:58 An: SAS-L@LISTSERV.UGA.EDU

Antwort an: Talbot Katz <TopKatz@MSN.COM>

Betreff: reading raw data Nachrichtentext:

Hi, gang.

It's your friendly twelve-year SAS novice back with another round of questions I should have known the answers to at least ten years ago.

When I get a new flat data file, I usually like to inspect a few records before reading into SAS data sets. Sometimes the files are too big to open with any of the editors I have around, so I try to use SAS to look at them. Ideally, I'd love to get output which looks like the SAS output that you get when you make a mistake reading something in -- you know, where it shows you each character in each column, even giving ascii or ebcdic codes along with the standard characters. Is there a way to get SAS to do this without having to make an error?

Here's something I did recently. I had a file which was supposed to have records of length between 200 and 250 characters, with 27 data fields, delimited by a '~' character. I wrote the following program :

data test ; infile "test.txt" missover lrecl = 32767 firstobs = 1 lastobs = 10 ; informat ir1 $char50. ; informat ir2 $char50. ; informat ir3 $char50. ; informat ir4 $char50. ; informat ir5 $char50. ; input @ 1 ir1 $ @ 51 ir2 $ @101 ir3 $ @151 ir4 $ @201 ir5 $ ; put ir1 ; put ir2 ; put ir3 ; put ir4 ; put ir5 ; run ;

I thought the char50 informat would make sure everything got scooped up, but I knew something was wrong in the printout, because each record stopped as soon as there was a blank space.

So I tried changing the input statement to : input @ 1 ir1 $char50. @ 51 ir2 $char50. @101 ir3 $char50. @151 ir4 $char50. @201 ir5 $char50. ;

That helped, but some records came out short in the output, and because they split in the middle of numeric fields at the right end, I knew the problem was at the left end -- leading blanks weren't being printed.

So I changed the output statements to : put @1 ir1 $char50. ; etc.

That printed out the first four fields, ir1 - ir4 correctly, but the last one, ir5, kept coming out blank. Luckily for me, the log told me that the minimum and maximum length records were the same size, in this case, 214. So, I changed all the "$char50." designations for ir5 to "$char14." and then it printed out something for the last field; it's probably correct, but I'm not sure, because the last twelve characters come out blank. Now, maybe they are blank, but then would SAS report them as part of the record length?

I think the file was just a standard windows ascii text file. Does SAS report unprintable characters, like carriage return and line feed, as part of the record length? Does SAS count trailing blanks as part of the record length?

Thanks!

-- TMK --

--

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet.

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.


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