Statistical File

This article describes how to connect Tableau to a statistical file and set up the data source.

Tableau connects to SAS (*.sas7bdat), SPSS (*.sav), and R (*.rdata, *.rda) data files.

Note: As of version 2020.1, Tableau no longer supports statistical files compressed with SASYZCR2. Use a different compression scheme to make the file readable for Tableau.

Make the connection and set up the data source

  1. Start Tableau and under Connect, select Statistical File, select the file that you want to connect to, and then select Open.

  2. On the data source page, do the following:

    1. (Optional) Select the default data source name at the top of the page, and then enter a unique data source name for use in Tableau. For example, use a data source naming convention that helps other users of the data source figure out which data source to connect to.

    2. Select the sheet tab to start your analysis.

      For information about connecting to more than one table, see Join Your Data.

Statistical file data source example

Here is an example of a statistical file data source using Tableau Desktop on a Windows computer:

Note the following:

  • The Statistical File connector does not support value labels.

  • The Statistical File connector supports only one table per statistical file.

    If an error message appears, "An error occurred while communicating with the data source," make sure that your statistical file contains only one object, and that the object is a data frame or a matrix. R files may contain hidden objects in what appears to be a clean workspace. To check for hidden objects, run ls(environment(), all.names=TRUE) from RStudio.

  • You can change the character encoding for a statistical file. For more information, see Change the character encoding for statistical files.

R data file object and format support

R data files should contain only one of the following types of objects:

  • Two-dimensional matrices

  • Vectors

  • Factors

  • Data frames

Note that if the R data file contains more than one object, Tableau will connect to the first one.

Tableau supports R data files that use binary format.

ASCII format files are not supported in Tableau Desktop. If you try to use an .rdata or .rda file with ASCII format, you’ll see an error saying, "Unable to read from file the table '' '[TableauTemp].[filename.rdata]' does not exist". In this case, you can use RStudio to save the file to a binary format, as follows:

  1. Download RStudio if you don’t already have it.
  2. Open your R data file in RStudio. You should see your data object in the global environment window on the upper right.
  3. Save the object to a new file with the "save()" function as follows:

    save(<objectName>,file="<filename>",ascii=FALSE)

    where: <objectName> is your data object, <filename> is the name of your new file, and "FALSE" is case-sensitive

    Tip: To quickly see documentation for this function, type "?save" at the command prompt.

Compressed files are not supported in Tableau Desktop. You must decompress files first with another program, such as Gzip or WinZip, before you connect with Tableau.

Change the character encoding for a statistical file

Tableau reads the data in a statistical file (for example, an SAS or R file) based on the file's character encoding or on information in an input file. R files typically use the character encoding of the operating system, compared to SAS and SPSS files, which include the character encoding information in the file. Sometimes, you might need to specify a different encoding. For example, if a colleague sends you a statistical file with Greek character encoding, then you must specify a Greek character set to use the file with Tableau. If you need to use a different character set when reading from a statistical file, you can create a Tableau data source customization (TDC) file and specify the encoding to use.

Create the TDC file

A .tdc file is an XML file that applies to a single data source and contains vendor and driver name information of the data source provider. For the statistical file connector, the vendor and driver name is stat-direct.

To create a TDC file:

  1. Open a plain text editor, such as Notepad.

  2. Copy the information from the sample provided below, paste it into your text file, and then specify the source-charset value. (For a list of encodings, see User-defined Encodings Supported by the Statistical File Connector.)

  3. Save the file with a .tdc extension—for example, r-statsfile.tdc—to the My Tableau Repository\Datasources folder.

Sample TDC file sets the source-charset value

The following TDC file example sets the source-charset value to shift-jis for a statistical file data source.

<connection-customization class='stat-direct' enabled='true' version='10.0'>
<vendor name='stat-direct' />
<driver name='stat-direct' />
  <customizations>
    <customization name='source-charset' value='shift-jis' />
  </customizations>
</connection-customization>

Important: Tableau does not test or support TDC files. These files should be used as a tool to explore or occasionally address issues with your data connection. Creating and maintaining TDC files requires careful manual editing, and there is no support for sharing these files.

About .ttde and .hhyper files

You might notice .ttde or .hhyper files when navigating your computer's directory. When you create a Tableau data source that connects to your data, Tableau creates a .ttde or .hhyper file. This file, also known as a shadow extract, is used to help improve the speed your data source loads in Tableau Desktop. Although a shadow extract contains underlying data and other information similar to the standard Tableau extract, a shadow extract is saved in a different format and can't be used to recover your data.

 

See also

Thanks for your feedback!Your feedback has been successfully submitted. Thank you!