BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ssomak
Fluorite | Level 6

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

1 ACCEPTED SOLUTION

Accepted Solutions
mkeintz
PROC Star

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.

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------

View solution in original post

5 REPLIES 5
mkeintz
PROC Star

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.

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
art297
Opal | Level 21

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

ssomak
Fluorite | Level 6

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

mkeintz
PROC Star

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.

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
ssomak
Fluorite | Level 6

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!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 28816 views
  • 2 likes
  • 3 in conversation