SAS Component Language Dictionary |
Category: | External File |
Syntax | |
Details | |
Example | |
See Also |
Syntax |
sysrc=FGET(file-id,cval<,length>); |
contains the return code for the operation:
0 | |
-1 |
the end of the FDB was reached, or no more tokens were available. |
is the identifier that was assigned when the file was opened. If file-id is invalid, the program halts.
is a character variable to hold the data.
Note: This parameter is an update parameter. See Input, Output, and Update Parameters for more information.
Details |
FGET copies data from the FDB into a character variable. If length is specified, then only the specified number of characters is retrieved (or the number of characters remaining in the buffer, if that number is less). If length is omitted, then all characters in the FDB from the current column position to the next delimiter are returned. The default delimiter is a blank. The delimiter is not retrieved. (See FSEP for more information about delimiters.)
After FGET is executed, the column pointer is automatically moved to the next "read" position in the FDB.
Example |
Read the first record in the file specified by the user and copy the first token into the variable THESTRING.
/* Assign the fileref THEFILE to the physical */ /* filename that is stored in the */ /* variable FNAME and open it in append mode. */ rc=filename( 'thefile',fname); fileid=fopen('thefile'); if (fileid>0) then do; /* Read the first record, retrieve the */ /* first token of the record and store */ /* it in the variable THESTRING. */ rc=fread(fileid); rc=fget(fileid,thestring); put thestring; rc=fclose(fileid); end; rc=filename('thefile','');
See Also |
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.