• <GetStart>
  • CSPro User's Guide
    • The CSPro System
    • Data Dictionary Module
    • The CSPro Language
    • Data Entry Module
    • Batch Editing Applications
    • Tabulation Applications
    • Data Sources
    • CSPro Statements and Functions
      • Statement Format Symbols
      • Alphabetical List of Functions and Statements
      • List of Reserved Words
      • Deprecated Features
      • Declaration Statements
      • Symbol Functions
      • Item Functions
      • Array Object
      • Audio Object
      • Barcode and QR Codes
      • Case Object
      • Document Object
      • File Object
      • Freq Object
      • Geometry Object
      • HashMap Object
      • Image Object
      • List Object
      • Map Object
      • Path
      • Pff Object
      • SystemApp Object
      • ValueSet Object
      • Program Control Statements
      • Assignment Statements
      • Data Entry Statements and Functions
      • Batch Edit Statements
      • Numeric Functions
      • String Functions
      • Multiple Occurrence Functions
      • General Functions
      • Date and Time Functions
      • External File Functions
        • Clear Function
        • Close Function
        • CountCases Function
        • CurrentKey Function
        • DelCase Function
        • DirCreate Function
        • DirDelete Function
        • DirExist Function
        • DirList Function
        • FileConcat Function
        • FileCopy Function
        • FileCreate Function
        • FileDelete Function
        • FileEmpty Function
        • FileExist Function
        • FileName Function
        • FileRead Function
        • FileRename Function
        • FileSize Function
        • FileTime Function
        • FileWrite Function
        • Find Function
        • Key Function
        • KeyList Function
        • LoadCase Function
        • Locate Function
        • NMembers Function
        • Open Function
        • Retrieve Function
        • Set Access Statement
        • SetFile Function
        • Set First Statement
        • Set Last Statement
        • Write Function
        • WriteCase Function
      • Synchronization Functions
    • Templated Reporting System
    • HTML and JavaScript Integration
    • Action Invoker
    • Appendix
  • <CSEntry>
  • <CSBatch>
  • <CSTab>
  • <DataViewer>
  • <TextView>
  • <TblView>
  • <CSFreq>
  • <CSDeploy>
  • <CSPack>
  • <CSDiff>
  • <CSConcat>
  • <Excel2CSPro>
  • <CSExport>
  • <CSIndex>
  • <CSReFmt>
  • <CSSort>
  • <ParadataConcat>
  • <ParadataViewer>
  • <CSCode>
  • <CSDocument>
  • <CSView>
  • <CSWeb>

FileWrite Function

Format
b = filewrite(file_handler, messageʃ, argument1, ..., argumentNʅ);
Description
The filewrite function writes one or more lines of text to the File associated with file_handler.
The message is either a string expression or a numeric message number that contains the text that is written to the file. If the text contains any message formatters, the optional arguments argument1 to argumentN will be inserted into the text. There are some additional options for file output:
  • If you want to break a line of text into two lines, place '\n' (newline) where you want the line divided.
  • If you want a text line to begin on a new page, place '\f' (form feed) at the beginning of the text string.
  • If using the Original logic version, to output \n or \f as text instead of a new line or a new page, use a double backslash (e.g., "\\n").
Alternatively, the message can be a string List. If a List is provided, then each string contained in the List is written to the file, allowing for the output of multiple lines of text with one function call.
File text can also be written using the File.writeText and File.writeLines actions.
Return Value
The function returns a logical value of 1 (true) if successful and 0 (false) otherwise.
Example
PROC GLOBAL

File CsvFile;

PROC EXAMPLE

   
filewrite(CsvFile, "Name,Sex,Age");

   
do numeric counter = 1 while counter <= totocc(PERSON_REC)
       
filewrite(CsvFile, "%s,%d,%d", encode(CSV, NAME(counter)), SEX(counter), AGE(counter));
   
enddo;
See also: FileRead Function, File.write Function, File.writeText Action, File.writeLines Action, Write Function, Message Formatting Options, Encode Function