SAS Component Language Dictionary |
Copies data from the File Data Buffer (FDB)
sysrc=FGET(file-id,cval<,length>);
|
-
rc
-
contains the return code for the operation:
0 |
successful |
-1 |
the end of the FDB was reached, or
no more tokens were available. |
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
-
cval
-
is a character variable to hold the data.
Note: This parameter is an update parameter. See
Input, Output, and Update Parameters for more information. ![[cautionend]](../../../../common/64368/HTML/default/images/cautend.gif)
Type:
Character
-
length
-
specifies how many characters to retrieve
from the FDB.
Type: Numeric
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.
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','');
FPOS
FREAD
FSEP
Copyright © 2011 by SAS Institute Inc., Cary, NC, USA. All rights reserved.