Chapter Contents

Previous

Next
FPUT

FPUT



Moves data to the File Data Buffer (FDB) of an external file, starting at the FDB's current column position, and returns a value

Category: External Files


Syntax
Arguments
Details
Examples
See Also

Syntax

FPUT(file-id,cval)

Arguments

file-id
specifies the identifier that was assigned when the file was opened, generally by the FOPEN function.

cval
specifies the file data. In a DATA step, cval can be a character string in quotation marks or a DATA step variable. In a macro, cval is a macro variable.


Details

FPUT returns 0 if the operation was successful, [ne]0 if it was not successful. The number of bytes moved to the FDB is determined by the length of the variable. The value of the column pointer is then increased to one position pas t the end of the new text.


Examples

This example assigns the fileref MYFILE to an external file and attempts to open the file in APPEND mode. If the file is opened successfully, indicated by a positive value in the variable FID, it moves data to the FDB using FPUT, ap pends a record using FWRITE, 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,a));
%if &fid > 0 %then
   %do;
      %let mystring=This is some data.;
      %let rc=%sysfunc(fput(&fid,&mystring));
      %let rc=%sysfunc(fwrite(&fid));
      %let rc=%sysfunc(fclose(&fid));
   %end;
%else
   %put %sysfunc(sysmsg());
%let rc=%sysfunc(filename(filrf));

See Also

Functions:

FCLOSE
FILENAME
FNOTE
FOPEN
FPOINT
FPOS
FWRITE
MOPEN
SYSMSG


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.