FCOL Function

Returns the current column position in the File Data Buffer (FDB).

Category: External Files

Syntax

FCOL(file-id)

Required Argument

file-id

is a numeric variable that specifies the identifier that was assigned when the file was opened, generally by the FOPEN function.

Details

Use FCOL combined with FPOS to manipulate data in the File Data Buffer (FDB).

Example

This example assigns the fileref MYFILE to an external file and attempts to open the file. If the file is successfully opened, indicated by a positive value in the variable FID, it puts more data into the FDB relative to position POS, writes the record, and closes the file:
%let filrf=myfile;
%let rc=%sysfunc(filename(filrf,
   physical-filename));
%let fid=%sysfunc(fopen(&filrf,o));
%if (&fid > 0) %then
   %do;
      %let record=This is data for the record.;
      %let rc=%sysfunc(fput(&fid,&record));
      %let pos=%sysfunc(fcol(&fid));
      %let rc=%sysfunc(fpos(&fid,%eval(&pos+1)));
      %let rc=%sysfunc(fput(&fid,more data));
      %let rc=%sysfunc(fwrite(&fid));
      %let rc=%sysfunc(fclose(&fid));
   %end;
%let rc=%sysfunc(filename(filrf));
The new record written to the external file is
This is data for the record. more data