FWRITE Function


Writes a record to an external file

Category: External Files

Syntax

FWRITE ( file-id <, cc >)

Arguments

file-id

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

cc

  • specifies a carriage -control character:

    blank

    starts the record on a new line.

    skips one blank line before a new line.

    -

    skips two blank lines before a new line.

    1

    starts the line on a new page.

    +

    overstrikes the line on a previous line.

    P

    interprets the line as a terminal prompt.

    =

    interprets the line as carriage control information.

    all else

    starts the line record on a new line.

Details

FWRITE returns 0 if the operation was successful, ‰  0 if it was not successful. FWRITE moves text from the File Data Buffer (FDB) to the external file. In order to use the carriage control characters , you must open the file with a record format of P (print format) in FOPEN.

Examples

This example assigns the fileref MYFILE to an external file and attempts to open the file. If the file is opened successfully, it writes the numbers 1 to 50 to the external file, skipping two blank lines. 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,o,0,P));  %do i=1 %to 50;     %let rc=%sysfunc(fput(&fid,        %sysfunc(putn(&i,2.))));     %if (%sysfunc(fwrite(&fid,-)) ne 0) %then       %put %sysfunc(sysmsg());  %end;  %let rc=%sysfunc(fclose(&fid)); 

See Also

Functions:

  • 'FAPPEND Function' on page 518

  • 'FCLOSE Function' on page 519

  • 'FGET Function' on page 527

  • 'FILENAME Function' on page 529

  • 'FOPEN Function' on page 550

  • 'FPUT Function' on page 557

  • '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