FREWIND Function


FREWIND Function

Positions the file pointer to the start of the file

Category: External Files

Syntax

FREWIND ( file-id )

Argument

file-id

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

Details

FREWIND returns 0 if the operation was successful, ‰  0 if it was not successful. FREWIND has no effect on a file opened with sequential access.

Examples

This example assigns the fileref MYFILE to an external file. Then it opens the file and reads the records until the end of the file is reached. The FREWIND function then repositions the pointer to the beginning of the file. The first record is read again and stored in the File Data Buffer (FDB). The first token is retrieved and stored in the macro variable VAL:

 %let filrf=myfile;  %let rc=%sysfunc(filename(filrf,  physical-filename  ));  %let fid=%sysfunc(fopen(&filrf));  %let rc=0;  %do %while (&rc ne -1);     /* Read a record. */     %let rc=%sysfunc(fread(&fid));  %end;     /* Reposition pointer to beginning of file. */  %if &rc = -1 %then    %do;      %let rc=%sysfunc(frewind(&fid));         /* Read first record. */      %let rc=%sysfunc(fread(&fid));         /* Read first token */         /* into macro variable VAL. */      %let rc=%sysfunc(fget(&fid,val));      %put val=&val;    %end;  %else    %put Error on fread=%sysfunc(sysmsg());  %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

  • 'FOPEN Function' on page 550

  • 'FREAD Function' on page 558

  • 'MOPEN Function' on page 656

  • 'SYSMSG Function' on page 847




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