FREAD Function


Reads a record from an external file into the File Data Buffer (FDB)

Category: External Files

Syntax

FREAD ( file-id )

Argument

file-id

  • specifies the identifier that was assigned when the file was opened, generally by the FOPEN function.

Details

FREAD returns 0 if the operation was successful, ‰  0 if it was not successful. The position of the file pointer is updated automatically after the read operation so that successive FREAD functions read successive file records.

To position the file pointer explicitly, use FNOTE, FPOINT, and FREWIND.

Examples

This example assigns the fileref MYFILE to an external file and attempts to open the file. If the file opens successfully, it lists all of the file's records in the log:

 %let filrf=myfile;  %let rc=%sysfunc(filename(filrf,  physical-filename  ));  %let fid=%sysfunc(fopen(&filrf));  %if &fid > 0 %then     %do %while(%sysfunc(fread(&fid)) = 0);        %let rc=%sysfunc(fget(&fid,c,200));             %put &c;        %end;     %let rc=%sysfunc(fclose(&fid));  %let rc=%sysfunc(filename(filrf)); 

See Also

Functions:

  • 'FCLOSE Function' on page 519

  • 'FGET Function' on page 527

  • 'FILENAME Function' on page 529

  • 'FNOTE Function' on page 548

  • 'FOPEN Function' on page 550

  • 'FREWIND Function' on page 559

  • 'FREWIND Function' on page 559

  • 'MOPEN Function' on page 656




SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3
SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 704

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net