XPORT (.stx, .xpt)

Background & Context

    • MIME type: application/x-sas-xport
    • SAS XPORT transport format.
    • Legacy data exchange format.
    • Stores numerical datasets in a portable format.
    • Text format.
    • Developed in the late 1980s by SAS Institute.

Import

  • Import["file.xpt"] imports an XPORT file, returning all datasets arranged as a table.
  • XPORT data is represented in the Wolfram Language by real or integer numbers, strings, Boolean values True and False, and DateObject specifications.
  • Import["file.xpt",elem] imports the specified element from an XPORT file.
  • Import["file.xpt",{elem,suba,subb,}] imports a subelement.
  • The import format can be specified with Import["file","XPORT"] or Import["file",{"XPORT",elem,}].
  • Export["file.xpt",expr] creates an XPORT file from expr.
  • Supported expressions expr include:
  • {v1,v2,}a single column of data
    {{v11,v12,},{v21,v22,},}lists of rows of data
    arrayan array such as SparseArray, QuantityArray, etc.
    tseriesa TimeSeries, EventSeries or TemporalData object
    Dataset[]a dataset
    <|"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 singleprecision numbers
    "Real64"IEEE doubleprecision numbers
    "String"string of characters
  • See the following reference pages for full general information:
  • Import, Exportimport from or export to a file
    CloudImport, CloudExportimport from or export to a cloud object
    ImportString, ExportStringimport from or export to a string
    ImportByteArray, ExportByteArrayimport from or export to a byte array

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
    "MissingPositions"positions of elements considered to be missing per column
    "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
    "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
  • Export options:
  • "ColumnDescriptions"Automaticlist of descriptions for each column
    "MetaInformation"Automaticassociation 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 all

Basic Examples  (3)

Import an XPORT file:

Summary of an XPORT file:

Export an array of expressions to an XPORT file:

Import the resulting file as a dataset:

Scope  (6)

Export a Dataset:

Column names are automatically inferred:

Export an array of data:

Column names are automatically generated:

Export an association of named columns:

Column names are automatically inferred:

Export a TimeSeries:

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

Export tagged missing data:

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

Import Elements  (13)

Data Representation  (3)

"Data"  (1)

Import an XPORT file as a 2D list of values:

This is also the default element:

"Dataset"  (1)

Import an XPORT file as a Dataset:

"LabeledData"  (1)

Import an XPORT 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 an XPORT file:

"Labels"  (1)

Import the names of each column in an XPORT file:

"MissingPositions"  (1)

Import associations giving the positions of missing values by column:

Metadata  (7)

"Comments"  (1)

Import comments stored in the metadata of an XPORT file:

"CreationDate"  (1)

Import the creation date:

"Dimensions"  (1)

Import the data dimensions:

"MetaInformation"  (1)

Import an association of all the metadata stored in an XPORT file:

"ModificationDate"  (1)

Import the modification date:

"TableName"  (1)

Import the table name stored in the metadata of an XPORT file:

"Version"  (1)

Import the version of an XPORT 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:

Export Options  (2)

"ColumnDescriptions"  (1)

Export different data types:

Columns will automatically infer types based on the data given:

Use "ColumnDescriptions" to specify column types and descriptions:

Import the resulting column descriptions:

"MetaInformation"  (1)

Retrieve the metainformation from an XPORT file:

Export a new file with the same metainformation: