Chapter Contents |
Previous |
Next |
FGET |
Category: | External Files |
Syntax | |
Arguments | |
Details | |
Examples | |
See Also |
Syntax |
FGET(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:
|
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.