SAS Component Language Dictionary |
Positions the file pointer at the beginning of the file
-
sysrc
-
contains the return code for the operation:
0 |
successful |
0 |
not successful |
Type: Numeric
-
file-id
-
contains the identifier that was assigned
when the file was opened. If file-id is invalid,
the program halts.
Type: Numeric
FREWIND has no effect on a file that was opened with
sequential access.
Assign the fileref THEFILE to an external file. Then
open the file and read 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 is stored in the File Data Buffer
(FDB). The first token is retrieved and is stored in the variable VAL.
/* Assign the fileref THEFILE to the physical */
/* filename stored in the variable FNAME */
/* and open it. */
rc=filename('thefile',fname);
fileid=fopen('thefile');
do while (rc ne -1);
/* Read a record. */
rc=fread(fileid);
end;
/* Reposition the pointer at the beginning of */
/* the file. */
if rc= -1 then rc=frewind(fileid);
/* Read the first record. */
rc=fread(fileid);
/* Read the first token into VAL. */
rc=fget(fileid,val);
put val= ;
rc=fclose(fileid);
rc=filename('thefile','');
FGET
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.