CSVDATA

<< Click to Display Table of Contents >>

Navigation:  Reference > RCPs >

CSVDATA

This RCP is needed if the data files being processed are CSV data files.

IMPORTANT: It should appear before the data files are defined with the C (cards) RCP.

When this RCP is present the data files should be of type CSV (Comma Separated Value).

Note: Variable names from CSV data are restricted to 27 characters (not the usual 30).

The CSV files must have a header row which identifies the variables to be created. The values in mvar (multi-coded) columns must be separated by spaces as found in portable CSV files created by Companion programs.

IMPORTANT: Note that cvars must have their size defined before the text is put into the variable from the CSV file.

Column headings are not case sensitive.

If a column contains serial numbers, you should include the SERIAL command at the top of the data stage:

serial number,                 ! Column should be headed SERIAL or IOBS

serial number 'Record number', ! Column should be headed Record number

Access to the data from each record is done using $* as the location.

Here are some simple example definitions of data from a CSV file when the CSV column header row contains the variable names:

ds $Q1=$*/1-4,

dm $Q2=$*/1,5,7,e,

di $Q3=$*,

dw $Q4=$*,

dc $Q5(20), dc $Q5=$*,

The $* can be followed by a text that will be used to identify the column to use for the variable:

ds $Q1=$*'Age of respondent'/1-4,

dm $Q2=$*'Car owned'/1,5,7,e,

di $Q3=$*'Cars owned',

dw $Q4=$*'Purchase price',

dc $Q5(20), dc $Q5=$*'Name of respondent',

Header texts can be up to 250 characters, must follow the normal text rules, and can be surrounded by apostrophes (') or speech marks (").

Note: If the heading is not found it will look for a column with the variable name instead (serial or iobs for the serial number).

Note: If a heading is allocated, it will be used for the VT and HT texts until these are overwritten, see Variable texts.

Example:

csvdata,