FPUT Function


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

Category: External Files

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, ‰  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 Function' on page 519

  • 'FILENAME Function' on page 529

  • 'FNOTE Function' on page 548

  • 'FOPEN Function' on page 550

  • 'FPOINT Function' on page 554

  • 'FPOS Function' on page 556

  • 'FWRITE Function' on page 564

  • 'MOPEN Function' on page 656

  • 'SYSMSG Function' on page 847




SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3
SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 704

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net