Spss.Document
Returns the cases, dictionary and value labels of an SPSS system file
(.sav, .zsav).
Syntax
Spss.Document(
source as binary,
optional options as record
) as table
Remarks
Reading an SPSS file in Power BI has historically meant owning SPSS, or routing
through the R or Python script host with haven or pyreadstat — an
interpreter to install and configure, and Service refresh scenarios that don't
work. This function decodes the system file format directly.
The result is a navigation table with three rows, because a survey file's dictionary is worth as much as its cases:
| Name | Contents |
|---|---|
Data | one row per case |
Variables | the data dictionary — name, label, type, format, measure, missing declarations |
ValueLabels | variable, value, label |
Options:
ApplyValueLabels: A logical (true/false). Replace coded values with their value labels inData; unlabeled values pass through (default is false).UserMissingToNull: A logical (true/false). Values declared user-missing in the dictionary, discrete or ranges, become null — matching how SPSS treats them in analysis (default is false). System-missing is always null.Encoding: ATextEncoding.Typeor codepage number for dictionary and data text, overriding what the file declares. Files declaring nothing default to Windows-1252.MaxRows: A number. Stop after this many cases.Strict: A logical (true/false). When true, tolerated malformations become errors — a trailing partial case, value-label indices pointing into the middle of a string, or numeric data found in a string column (default is false).
Examples
Example #1
Read the cases.
let
Doc = Spss.Document(File.Contents("C:\data\survey.sav")),
Data = Doc{[Name = "Data"]}[Data]
in
Data