DATA Step, Macro, Functions and more

lrecl option

Reply
Super Contributor
Posts: 345

lrecl option

I need to read a large dataset, infile from *.dat

I set irecl=32767 the maxim value

 

the log showed

The minimum record length was 20000.

The maximum record length was 20000.

and for the date, the log showed a warning

"has already been defined as numeric"

 

 

 

Any advice how to change irecl to the right value?

Super User
Posts: 7,762

Re: lrecl option

Show log (with relevant code). LRECL is not the reason for the WARNING.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super Contributor
Posts: 345

Re: lrecl option

Posted in reply to KurtBremser

you are right.

I find sas stops before the varible "date", so I format the date, then there is a warning

it seems not necessary to format

all are charcters, no delimiters, a lot of space, so I have all the code with the location and length of the variables

 

INFILE 'c:\abc.DAT' truncover lrecl=30000

obs=300;

   INPUT  
@59 id $1.		@139 fname4 $4.	..
@11593 cdc $8.;
Run;
Super Contributor
Posts: 345

Re: lrecl option

I adjusted irecl from 20000 to the maxim, the record is 20000

but it dos not read right for the rest part

Super User
Posts: 7,762

Re: lrecl option

This is not the log, just part of the code.

To help you, we need the whole log of the data step including the ERROR message.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super Contributor
Posts: 345

Re: lrecl option

Posted in reply to KurtBremser

see my log below, please

Super User
Posts: 7,762

Re: lrecl option

To repeat myself:

To help you, we need the whole log of the data step including the ERROR message.

Whole log means "including the code that caused the ERROR".

Just copy/paste from the log; it's not rocket science.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
PROC Star
Posts: 1,759

Re: lrecl option

[ Edited ]

so your code reads:

 

format DATE date9.;
input  ....   DATE $8. .... ;

 

Well the error is exactly was it says: you have defined the variable as numeric (with the format statement) and then you want to read it as a string. 

 

Formatting the date will not force reading its value. You have to look at where in the record the reading stops and why. One way to do it is

 

infile ... lrecl=30000 pad truncover;
input X $30000.;

and then use substr() to analyse the contents of X (use _infile_ instead of X if you know about _infile_, otherwise just use the X variable to do your investigation).

 

 

Super Contributor
Posts: 345

Re: lrecl option

Thanks

I tried yours. it does not change, still it cant not read the rest part

 

5 records were read from the infile

' c:\abc.DAT'.

The minimum record length was 20000.

The maximum record length was 20000.

NOTE: The data set WORK.CONTEST has 5 observations and 213 variables.

NOTE: DATA statement used (Total process time):

real time 0.17 seconds

cpu time 0.07 seconds

 

PROC Star
Posts: 1,759

Re: lrecl option

1) How long is your text file record length? At least 20k it seems; try using lrecl=32767

 

2) What's the position of the date in the record?

Super Contributor
Posts: 345

Re: lrecl option

I do not understand that, "What's the position of the date in the record?"

 

I have adjusted the value of lrecl, with many different values, it did not work

PROC Star
Posts: 1,759

Re: lrecl option

"What's the position of the date in the record?"  means: how many characters do you have to count on your text input record before the date is found?

Ask a Question
Discussion stats
  • 11 replies
  • 474 views
  • 0 likes
  • 3 in conversation