• <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
        • EndCase Statement
        • Export Statement
        • Freq Statement (Unnamed)
        • GetDeck Function
        • PutDeck Function
        • Set Behavior Export Statement
        • SetOutput Function
        • Skip Case Statement
      • Numeric Functions
      • String Functions
      • Multiple Occurrence Functions
      • General Functions
      • Date and Time Functions
      • External File Functions
      • 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>

Export Statement

Format
export to file_name
         
ʃrec_name(record_name | alpha_exp)ʅ
         
ʃrec_type(record_name | alpha_exp)ʅ
         
ʃcase_id (ʃitem_list]ʅ)ʅ
         record_item_list;
Description
The export statement writes a record to an export file. Export statements can only be coded in level procedures.
In the to phase, the file_name is a name declared in the File Statement in PROC GLOBAL.
The rec_name, rec_type, and case_id phrases can each be coded only once, but can be coded in any order. They all must be coded before record_item_list. The order in which rec_type and case_id are coded determines the order of output of the record type and case ids in the exported record.
The rec_name phrase is optional and is only needed when data are exported to CSPro format. When used, the label and name from the record name in the input dictionary is used for the label and name of the record type created in the exported dictionary. If an alpha_exp is coded, then the label of the record type in the exported data dictionary is the result of the alphanumeric expression and the name is derived from the label. If rec_name is not coded, the labels and record names in the newly-created dictionary will be RECORD001, RECORD002, etc.
The rec_type phrase is optional. When coded it places a record type on the exported data record. If a record_name is coded, then the record type value from the record name in the input data dictionary is placed on the exported data file. If an alpha_exp is coded, then the value of the expression is placed on the exported data file.
The case_id phrase is optional. When coded it is used to place case identifiers on the exported data record. If case_id() is coded then ALL the case ids from the level in which the export statement is coded are placed on the exported data record. If no case_id phrase is coded and export format is CSPro, the ALL case ids from ALL levels will be output.
The record_item_list specifies the contents of the exported data record. This can be any combination of record names or item names.
Where possible users are encouraged to use the Export Data tool instead of the export statement.
Example
// Export fertility data for women 15 to 54 years old
PROC GLOBAL

File SPSS_EXPORT;

PROC CENSUS_2000_DICTIONARY_FF

PROC QUEST // export done at LEVEL procedure

   
set behavior() export(SPSS, ItemOnly);

   
do numeric i = 1 until i > totocc(PERSON)
       
if P03_SEX(i) = 2 and P04_AGE(i) in 15:54 then
           
export to SPSS_EXPORT
                     
case_id(PROVINCE, DISTRICT, EA, HU, HH)
                      LINE(i), P18_BORN(i), P19_LIVING(i), P20_BORN12(i);
           
errmsg("Record exported for female ages 15-54") summary;
       
endif;
   
enddo;
See also: Newline Handling, Set Behavior Export Statement, File Statement, SetFile Function, Introduction to Export Data