ASCII Files - Delimited

Stat/Transfer will read and write delimited ASCII.  Note that as of version 10, "ASCII" is used as a shorthand, since Stat/Transfer supports a variety of character sets besides ASCII.  If you need to read or write data  in a character set that is something other than your system's default character set, you will need to set the encoding options.

 

Standard extension:  txt. csv

 

Reading ASCII Delimited Files

When reading ASCII delimited files, you can use the user interface or command processor options to specify:

 

  • What character is read as the delimiter.  You can explicitly specify the character or you can allow the program to sense it automatically.

 

  • That Stat/Transfer should combine adjacent blank delimiters.

 

  • Whether or not the first row is treated as variable names, or whether Stat/Transfer should automatically sense it or whether Stat/Transfer should assign field names.

 

  • The character that is used to enclose string fields in the input data.

 

  • The number of lines Stat/Transfer will read to determine each type of variable present.  By default the entire data set is read.

 

  • What character is read as missing value.

 

  • The decimal point and thousands separator in your data.

 

  • The user-defined DateTime format is used to determine whether a given field is a date, time or a date/time.  The formats for dates, times and date/times are then used to actually read the data.  If your dates are not in the default MDY format, you will need to change the formats in the option settings

  • A century changeover year.  If you are reading two-digit years, you can use this option to control how they are read.  The default for the option is '30'.

All of the user interface options available for reading ASCII files are set in the Options dialog box, in the sections Date/Time Formats - Reading and ASCII/Text File - Read Options.  The command processor options can be found in Setting Options with the Set Command.

 

If you wish to have more flexibility in reading delimited files, you can describe the file with a Schema file.

 

Writing ASCII Files

When writing ASCII delimited files, you can specify:

 

  • The character that will be used as the delimiter in each record:  commas, tabs, spaces, semicolons, or some other character.

 

  • The character that will be used to enclose string variables on output.  It is typically a double quote.

 

  • What character will be used for missing values.

 

  • What line ending to use.

 

  • The date and time formats.

 

  • Whether Stat/Transfer should write variable names in the first row of the output.

All of the options available for writing ASCII files are set in the Options dialog box, in the sections Date/Time Formats - Writing and ASCII/Text File - Write Options.  The command processor options can be found in Setting Options with the Set Command.

 

Missing Values

By default, missing values are indicated on input and output by one delimiter immediately following another.  You may change this default behavior in the ASCII/Text File - Write Options section of the Options dialog box.  Extended missing values are supported.

 

When an ASCII file with extended missing values is transferred to a SAS or Stata file, the input missing values will transfer to the equivalent SAS ones.  When a SAS file is transferred to an ASCII file with extended missing values specified, any missing values '._' in the input SAS file are written out as  '.' in the output.

 

Note that if a blank is used as the delimiter, missing values will be hard to determine.

 

Output Variable Types

The output variable type that results from each target variable type is given in the following table:

 

 

Target Type

Output Type

 

byte

int

long

float

double

Number (with a precision of up to 15 decimal places)

 

string

Character

 

date

time

date/time

Character (written using ASCII format options currently in effect)

 

See also:

ASCII Schema Files