DTA (.dta)

Background

    • MIME type: application/x-stata-dta
    • Stata database transport format.
    • Legacy data exchange format.
    • Stores numerical datasets in a portable format.
    • Binary format.
    • Initially developed in 1985 by StataCorp.

Import & Export

  • Import["file.dta"] imports a DTA file, returning all datasets arranged as a table.
  • DTA data is represented in the Wolfram Language by real or integer numbers, strings, Boolean values True and False, and DateObject specifications.
  • Import["file.dta",elem] imports the specified element from a DTA file.
  • Import["file.dta",{elem,suba,subb,}] imports a subelement.
  • The import format can be specified with Import["file","DTA"] or Import["file",{"DTA",elem,}].
  • See the reference pages for full general information on Import.
  • ImportString supports the DTA format.

Import Elements

  • General Import elements:
  • "Elements" list of elements and options available in this file
    "Rules"full list of rules for each element and option
    "Options"list of rules for options, properties and settings
    "Summary"summary of file size and dimensions
  • Data representation elements:
  • "Data"two-dimensional array
    "Dataset"table data as a Dataset
    "LabeledData"association of labels and data
  • Import by default uses the "Data" element.
  • Data descriptor elements:
  • "LabelDescriptions"description and types of columns
    "Labels"names of columns
    "MissingValues"values to be considered missing per column
  • Metadata elements:
  • "ByteOrdering"endianness of the data
    "CharacterEncoding"character encoding of the file
    "Comments"comments on the file
    "Compression"type of compression used in the file
    "CreationDate"creation date of the document, given as a DateObject
    "Dimensions"dimensions of the data
    "MetaInformation"metadata given as strings and date objects
    "MissingValues"values to be considered missing per column
    "ModificationDate"modification date of the document, given as a DateObject
    "TableName"name of the entire table
    "Version"version of the SAS specification for the file

Options

  • Import options:
  • "ColumnDefaultValues"Automaticassociation of column names and default values
    "TypeDefaultValues"Automaticassociation of types and default values

Examples

open allclose all

Basic Examples  (2)

Import a DTA file:

Summary of a DTA file:

Import Elements  (13)

Data Representation  (3)

"Data"  (1)

Import a DTA file as a 2D list of values:

This is also the default element:

"Dataset"  (1)

Import a DTA file as a Dataset:

"LabeledData"  (1)

Import a DTA file as an association of labels and data:

Data Descriptors  (3)

"LabelDescriptions"  (1)

Import associations giving the name, description and type for each column in a DTA file:

"Labels"  (1)

Import the names of each column in a DTA file:

"MissingPositions"  (1)

Import associations giving the positions of missing values by column:

Metadata  (7)

"ByteOrdering"  (1)

Import the byte ordering stored in the metadata of a DTA file:

"Comments"  (1)

Import comments stored in the metadata of a DTA file:

"CreationDate"  (1)

Import the creation date:

"Dimensions"  (1)

Import the data dimensions:

"MetaInformation"  (1)

Import an association of all the metadata stored in a DTA file:

"ModificationDate"  (1)

Import the modification date:

"Version"  (1)

Import the version of a DTA file:

Import Options  (2)

"ColumnDefaultValues"  (1)

Missing numerical values are replaced with zero by default:

Use "ColumnDefaultValues" to specify a different default value for specific columns:

"TypeDefaultValues"  (1)

Missing numerical values are replaced with zero by default:

Use "TypeDefaultValues" to specify a different default value for specific types: