DTA (.dta)
Background & Context

-
- 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,…}].
- Export["file.dta",expr] creates a DTA file from expr.
- Supported expressions expr include:
-
{v1,v2,…} a single column of data {{v11,v12,…},{v21,v22,…},…} lists of rows of data array an array such as SparseArray, QuantityArray, etc. tseries a TimeSeries, EventSeries or TemporalData object Dataset[…] a dataset Tabular[…] a tabular object <"name1"expr1,… > an association of named columns - Import and Export support the following data types:
-
"Date" date and time specifications "Integer8" 8-bit integers "Integer16" 16-bit integers "Integer32" 32-bit integers "Real32" IEEE single‐precision numbers "Real64" IEEE double‐precision numbers "String" string of characters - See the following reference pages for full general information:
-
Import, Export import from or export to a file CloudImport, CloudExport import from or export to a cloud object ImportString, ExportString import from or export to a string ImportByteArray, ExportByteArray import from or export to a byte array
Import Elements


- General Import elements:
-
"Elements" list of elements and options available in this file "Summary" summary of the file "Rules" list of rules for all available elements - Data representation elements:
-
"Data" two-dimensional array "Dataset" table data as a Dataset "LabeledData" association of labels and data "LabeledRawData" association of labels and raw data "Tabular" table data as a Tabular object - Import by default uses the "Data" element.
- Data descriptor elements:
-
"ColumnDescriptions" 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" Automatic association of column names and default values "TypeDefaultValues" Automatic association of types and default values - Export options:
-
"ColumnDescriptions" Automatic list of descriptions for each column "MetaInformation" Automatic association of metadata tags and values - Possible settings for "ColumnDescriptions" include:
-
{"label1", "label2", …} list of strings giving column names {assoc,…} list of associations giving column metadata <colassoc > association of index or column name and column metadata - Possible keys for assoc include:
-
"Name" string giving the column's name "Description" string giving the column's description "Type" string giving the column's type - Possible keys for "MetaInformation" include:
-
"Comments" string giving general comments on the file "CreationDate" date object giving the creation date of the file "ModificationDate" date object giving the modification date of the file "TableName" string giving the name of the entire table "Version" integer giving the version of the file
Examples
open allclose allBasic Examples (3)Summary of the most common use cases

https://wolfram.com/xid/0qn77l5fk-f3zba1


https://wolfram.com/xid/0qn77l5fk-jorcfv

Export an array of expressions to a DTA file:

https://wolfram.com/xid/0qn77l5fk-t64ayh


https://wolfram.com/xid/0qn77l5fk-lfzmgr

Scope (9)Survey of the scope of standard use cases
Import (3)
Import all available elements:

https://wolfram.com/xid/0qn77l5fk-6rk6nf


https://wolfram.com/xid/0qn77l5fk-7u7lw9

Import as a Tabular object:

https://wolfram.com/xid/0qn77l5fk-zvfkuo

Export (6)
Export a Dataset:

https://wolfram.com/xid/0qn77l5fk-nymkfr


https://wolfram.com/xid/0qn77l5fk-c2e4vv
Column names are automatically inferred:

https://wolfram.com/xid/0qn77l5fk-w6cl5m


https://wolfram.com/xid/0qn77l5fk-67nm6u

Column names are automatically generated:

https://wolfram.com/xid/0qn77l5fk-k8h2kn

Export an association of named columns:

https://wolfram.com/xid/0qn77l5fk-bd3kmi

Column names are automatically inferred:

https://wolfram.com/xid/0qn77l5fk-m2dh74

Export a TimeSeries:

https://wolfram.com/xid/0qn77l5fk-byvcsb

https://wolfram.com/xid/0qn77l5fk-dhklb2


https://wolfram.com/xid/0qn77l5fk-pbot5s

Times are stored in the first column, values in the second:

https://wolfram.com/xid/0qn77l5fk-n5f84h


https://wolfram.com/xid/0qn77l5fk-7ff2si


https://wolfram.com/xid/0qn77l5fk-e4bnr8

Ragged arrays are automatically padded on the right and converted to full arrays:

https://wolfram.com/xid/0qn77l5fk-fyo5zt


https://wolfram.com/xid/0qn77l5fk-s6tjg7

Import Elements (15)
Data Representation (5)
"Data" (1)
"Dataset" (1)
Import a DTA file as a Dataset:

https://wolfram.com/xid/0qn77l5fk-sya0vk

"LabeledData" (1)
"LabeledRawData" (1)
"Tabular" (1)
Import a DTA file as a Tabular:

https://wolfram.com/xid/0qn77l5fk-3ossbj

Data Descriptors (3)
"ColumnDescriptions" (1)
"Labels" (1)
Metadata (7)
"ByteOrdering" (1)
"Comments" (1)
"CreationDate" (1)
"Dimensions" (1)
"MetaInformation" (1)
"ModificationDate" (1)
Import Options (2)
"ColumnDefaultValues" (1)
Missing numerical values are replaced with zero by default:

https://wolfram.com/xid/0qn77l5fk-n5ii94

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

https://wolfram.com/xid/0qn77l5fk-dgadw6

"TypeDefaultValues" (1)
Missing numerical values are replaced with zero by default:

https://wolfram.com/xid/0qn77l5fk-upa1l6

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

https://wolfram.com/xid/0qn77l5fk-md0rn7

Export Options (2)
"ColumnDescriptions" (1)

https://wolfram.com/xid/0qn77l5fk-62u9lb

Columns will automatically infer types based on the data given:

https://wolfram.com/xid/0qn77l5fk-xwddl4

Use "ColumnDescriptions" to specify column types and descriptions:

https://wolfram.com/xid/0qn77l5fk-la95ti

Import the resulting column descriptions:

https://wolfram.com/xid/0qn77l5fk-6gupky

"MetaInformation" (1)
Retrieve the metadata from a DTA file:

https://wolfram.com/xid/0qn77l5fk-nsjlm4

Export a new file with the same metadata:

https://wolfram.com/xid/0qn77l5fk-7pewnv


https://wolfram.com/xid/0qn77l5fk-j0kjjx
