- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
--------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
--------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Which version of SAS are you on and with which operating system? The following might be relevant:
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
--------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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!