SAS7BDAT (.sas7bdat)
Updatedshow changes
Background & Context

-
- MIME type: application/x-sas-data
- SAS database transport format.
- Legacy data exchange format.
- Stores numerical datasets in a portable format.
- Binary format.
- Developed in the late 1980s by SAS Institute.
Import & Export


- Import["file.sas7bdat"] imports a SAS7BDAT file, returning all datasets arranged as a table.
- SAS7BDAT data is represented in the Wolfram Language by real or integer numbers, strings, Boolean values True and False, and DateObject specifications.
- Import["file.sas7bdat",elem] imports the specified element from a SAS7BDAT file.
- Import["file.sas7bdat",{elem,suba,subb,…}] imports a subelement.
- The import format can be specified with Import["file","SAS7BDAT"] or Import["file",{"SAS7BDAT",elem,…}].
- Export["file.sas7bdat",expr] creates a SAS7BDAT 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 a 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 "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" 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
In[1]:=1

✖
https://wolfram.com/xid/0ztzgfr17sumcwx0x-f3zba1
Out[1]=1

In[1]:=1

✖
https://wolfram.com/xid/0ztzgfr17sumcwx0x-lx9i0
Out[1]=1

Export an array of expressions to a SAS7BDAT file:
In[1]:=1

✖
https://wolfram.com/xid/0ztzgfr17sumcwx0x-t64ayh
Out[1]=1

Import the resulting file as a dataset:
In[2]:=2

✖
https://wolfram.com/xid/0ztzgfr17sumcwx0x-lfzmgr
Out[2]=2

Scope (9)Survey of the scope of standard use cases
Import (3)
Import all available elements:
In[2]:=2

✖
https://wolfram.com/xid/0ztzgfr17sumcwx0x-6rk6nf
Out[2]=2

In[1]:=1

✖
https://wolfram.com/xid/0ztzgfr17sumcwx0x-7u7lw9
Out[1]=1

Import as a Tabular object:
In[1]:=1

✖
https://wolfram.com/xid/0ztzgfr17sumcwx0x-zvfkuo
Out[1]=1

Export (6)
Export a Dataset:
In[1]:=1

✖
https://wolfram.com/xid/0ztzgfr17sumcwx0x-nymkfr
Out[1]=1

In[2]:=2

✖
https://wolfram.com/xid/0ztzgfr17sumcwx0x-c2e4vv
Column names are automatically inferred:
In[3]:=3

✖
https://wolfram.com/xid/0ztzgfr17sumcwx0x-w6cl5m
Out[3]=3

In[1]:=1

✖
https://wolfram.com/xid/0ztzgfr17sumcwx0x-67nm6u
Out[1]=1

In[2]:=2

✖
https://wolfram.com/xid/0ztzgfr17sumcwx0x-k8h2kn
Out[2]=2

Export an association of named columns:
In[1]:=1

✖
https://wolfram.com/xid/0ztzgfr17sumcwx0x-bd3kmi
Out[1]=1

Column names are automatically inferred:
In[2]:=2

✖
https://wolfram.com/xid/0ztzgfr17sumcwx0x-m2dh74
Out[2]=2

Export a TimeSeries:
In[1]:=1

✖
https://wolfram.com/xid/0ztzgfr17sumcwx0x-byvcsb
In[2]:=2

✖
https://wolfram.com/xid/0ztzgfr17sumcwx0x-dhklb2
Out[2]=2

In[3]:=3

✖
https://wolfram.com/xid/0ztzgfr17sumcwx0x-pbot5s
Out[3]=3

Times are stored in the first column, values in the second:
In[4]:=4

✖
https://wolfram.com/xid/0ztzgfr17sumcwx0x-n5f84h
Out[4]=4

In[1]:=1

✖
https://wolfram.com/xid/0ztzgfr17sumcwx0x-7ff2si
Out[1]=1

In[2]:=2

✖
https://wolfram.com/xid/0ztzgfr17sumcwx0x-e4bnr8
Out[2]=2

Ragged arrays are automatically padded on the right and converted to full arrays:
In[1]:=1

✖
https://wolfram.com/xid/0ztzgfr17sumcwx0x-fyo5zt
Out[1]=1

In[2]:=2

✖
https://wolfram.com/xid/0ztzgfr17sumcwx0x-s6tjg7
Out[2]=2

Import Elements (17)
Data Representation (5)
Data Descriptors (3)
"ColumnDescriptions" (1)
"Labels" (1)
Metadata (9)
"ByteOrdering" (1)
"CharacterEncoding" (1)
"Comments" (1)
"CreationDate" (1)
"Dimensions" (1)
"MetaInformation" (1)
"ModificationDate" (1)
"TableName" (1)
Import Options (2)
"ColumnDefaultValues" (1)
Export Options (2)
"ColumnDescriptions" (1)
In[1]:=1

✖
https://wolfram.com/xid/0ztzgfr17sumcwx0x-62u9lb
Out[1]=1

Columns will automatically infer types based on the data given:
In[2]:=2

✖
https://wolfram.com/xid/0ztzgfr17sumcwx0x-xwddl4
Out[2]=2

Use "ColumnDescriptions" to specify column types and descriptions:
In[3]:=3

✖
https://wolfram.com/xid/0ztzgfr17sumcwx0x-la95ti
Out[3]=3

Import the resulting column descriptions:
In[4]:=4

✖
https://wolfram.com/xid/0ztzgfr17sumcwx0x-6gupky
Out[4]=4

"MetaInformation" (1)
Retrieve the metainformation from a SAS7BDAT file:
In[1]:=1

✖
https://wolfram.com/xid/0ztzgfr17sumcwx0x-nsjlm4
Out[1]=1

Export a new file with the same metainformation:
In[2]:=2

✖
https://wolfram.com/xid/0ztzgfr17sumcwx0x-7pewnv
Out[2]=2

In[3]:=3

✖
https://wolfram.com/xid/0ztzgfr17sumcwx0x-j0kjjx
Out[3]=3
