SAS Component Language Dictionary |
Returns the size of the last record read, or, if the file is opened
for output, returns the current record size
-
length
-
contains the length of the current record
if the file is opened for output. Otherwise, it is the length of the last
record read.
Type: Numeric
-
file-id
-
is the identifier that was assigned when
the file was opened. If file-id is invalid, the
program halts.
Type: Numeric
Open the file identified by the fileref THEFILE. Determine
the minimum and maximum lengths of records in the external file,
and write the results to the LOG window.
/* Assign the fileref THEFILE to the physical */
/* filename stored in the variable FNAME */
/* and open it. */
rc=filename('thefile',fname);
fileid=fopen('thefile');
min=0;
max=0;
if (fread(fileid)=0) then do;
min=frlen(fileid);
max=min;
do while(fread(fileid)=0);
reclen=frlen(fileid);
if (reclen>max) then max=reclen;
if (reclen<min) then min=reclen;
end;
rc=fclose(fileid);
end;
put min= max=;
FCLOSE
FOPEN
FREAD
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.