DATA Step, Macro, Functions and more

Maximum record length problem (LRECL in infile statement)

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 5
Accepted Solution

Maximum record length problem (LRECL in infile statement)

Hi all,

I've got a problem with maximum record length. When I'm trying to create data set from external file in the following way:

     data test;

          infile "path_to_my_file"

          LRECL=22000

          ENCODING="UTF-8"

          TERMSTR=CRLF

          MISOVER

          PAD

          input

          /* columns here */

          ;

     run;

SAS is setting maximum record length to 14977 - this is what I see in log:

 

     NOTE: The infile "path_to_my_file" is:

          Filename=path_to_my_file,

          RECFM=V,LRECL=132006,

          File Size (bytes)=103939281,

          Last Modified=02 sierpień 2012 14:38:59,

          Create Time=02 sierpień 2012 14:38:36

     NOTE: 6939 records were read from the infile "path_to_my_file".

          The minimum record length was 14977.

          The maximum record length was 14977.

As noted above, LRECL is set to 132006 (instead of 22000 as I coded) and max record length is 14977.

Whats more, when I doing the same in SAS DI using 'File->New->Fixed Width' and setting 'Logical record length' to 22000, then, in code preview, LRECL is also set to 14977...

Anyone have some idea what's going on?

I will be grateful for any help.

Thanks in advance!

Kamil


Accepted Solutions
Solution
‎08-17-2012 10:43 AM
Trusted Advisor
Posts: 1,022

Re: Maximum record length problem (LRECL in infile statement)

You haven't identified the problem yet.

And note the LRECL has not been "set" by SAS to 14,977.  It already is that length (at least that's the distance between consecutive CRLF's in the input file) - SAS is just telling you about the incoming data.  If you are saying that input data ought to be 22,000 then you should confer with the person who created it, because it's short by 7,023.

If that's not the issue, the you should tell us what the input data looks like, what you expected to produce, and what you got.

View solution in original post


All Replies
Trusted Advisor
Posts: 1,022

Re: Maximum record length problem (LRECL in infile statement)

The infile note is, I believe, constructed before actual data is processed (note the report on number of records encountered and .maximum/minimum lengths observed followed that note).

So I suspect that the file was created as recfm=V and (maximum) lrecl of 132006.  At least that's how it might have been done in the old mainframe days: the file header would have had such metadata in it and SAS reports it.  Are you running SAS on z/OS?

Now, when you set your LRECL to 22000, you were only telling SAS that 22000 is the maximum expected length (after all the record format is "V" - for "variable length").  After processing SAS reported that all the records turned out to be 14,977 bytes long, even though SAS was prepared for up to 22000 bytes and the operating system would have supported up to 132006 bytes.

PROC Star
Posts: 7,492

Re: Maximum record length problem (LRECL in infile statement)

Which version of SAS are you on and with which operating system?  The following might be relevant:

http://support.sas.com/kb/37/173.html

Occasional Contributor
Posts: 5

Re: Maximum record length problem (LRECL in infile statement)

Hi guys,

Thanks for your answers! Unfortunatelly I still don't know how to correctly import this file ('wide' .txt file). I'm using SAS 9.2 under Windows enviroment. Do you have any idea how should I implement data step to correctly import such a file?

Thanks in advance!

Kamil

Solution
‎08-17-2012 10:43 AM
Trusted Advisor
Posts: 1,022

Re: Maximum record length problem (LRECL in infile statement)

You haven't identified the problem yet.

And note the LRECL has not been "set" by SAS to 14,977.  It already is that length (at least that's the distance between consecutive CRLF's in the input file) - SAS is just telling you about the incoming data.  If you are saying that input data ought to be 22,000 then you should confer with the person who created it, because it's short by 7,023.

If that's not the issue, the you should tell us what the input data looks like, what you expected to produce, and what you got.

Occasional Contributor
Posts: 5

Re: Maximum record length problem (LRECL in infile statement)

Hi again,

mkeintz - you were right, the problem was with the file (shame on me I didn't checked it earlier...). Once again many thanks for help!

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 13945 views
  • 1 like
  • 3 in conversation