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 (June 2001, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Wed, 20 Jun 2001 06:23:59 -0400
Reply-To:   Gerhard Hellriegel <ghellrieg@T-ONLINE.DE>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Gerhard Hellriegel <ghellrieg@T-ONLINE.DE>
Subject:   Re: Reading varying length record with datalines

On Wed, 20 Jun 2001 10:44:00 +0200, Dietrich Alte <alte@MAIL.UNI- GREIFSWALD.DE> wrote:

>Hi all, > >I have records like > >Var1 Var2 >--------------------------- >house My house is my castle. >cat It is raining cats and dogs > >and want to read them from datalines in one step. > >In the infile statement you can state truncover and/or use the varying >format in order to read the sentence into one variable. > >How can this be achieved? Truncover doesn't work with datalines, for >the varying format I need a length variable, but the statement length >ist not abailable. > >Any help welcome. > >TIA > >-- >----------------------------------------------------------------- > Dietrich Alte (Statistician, Dipl.-Stat.) > University of Greifswald - Medical Faculty > Institute of Epidemiology and Social Medicine > Walther-Rathenau-Str. 48, D-17487 Greifswald, Germany > Phone +49 (0) 3834 - 86 77 13, fax +49 (0) 3834 - 86 66 84 > Email alte@mail.uni-greifswald.de > Institute http://www.medizin.uni-greifswald.de/epidem/ > Study http://www.medizin.uni-greifswald.de/epidem/ship.htm >-----------------------------------------------------------------

That is dependant on the operating system. I assume you have Windows, not MVS. In windows you do not have any length informations about each record. MVS has a length field for each record if the format is V or VB. In Win there are no records, all is a kind of "stream" file! The "records" are delimited by certain hex-chars (LF/CR = Linefeed/Carriage Return). You have at least two possibilities of reading that: 1. you read the stream as stream of bytes and look for the record- delimiters. This you can do with the RECFM=N option in the infile statement. 2. you can read it with a LRECL which is more than your longest record. For that you should specify the TRUNCOVER option to prevent SAS going to the next record if one is shorter than you input statement. The input statement should also be as long as your longest record. Otherwise it will be truncated. The LRECL option has only influence to the input buffer, not on what you are doing with that buffer. The kind of operation on the buffer is described by the input statement. The description of the buffer is located at the INFILE statement. The RECFM=N reads unbuffered as "stream of bytes".


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