SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3

Copies data from the File Data Buffer (FDB) into a variable

Category: External Files

Syntax

FGET ( file-id , variable <, length >)

Arguments

file-id

variable

length

Details

FGET returns 0 if the operation was successful, or -1 if the end of the FDB was reached or no more tokens were available.

After FGET is executed, the column pointer moves to the next read position in the FDB.

Examples

This example assigns the fileref MYFILE to an external file and attempts to open the file. If the file is opened successfully, it reads the first record into the File Data Buffer, retrieves the first token of the record and stores i t in the variable MYSTRING, and then closes the file. Note that in a macro statement you do not enclose character strings in quotation marks.

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

See Also

Functions:

Категории