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.
Start Tableau and under Connect, select Statistical File, select the file that you want to connect to, and then select Open.
On the data source page, do the following:
(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.
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 files should contain only one of the following types of objects:
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 save the file to a supported format, such as .rdx, as follows:
- Download RStudio if you don’t already have it.
- Open your file in RStudio.
- Save the file in RStudio. This will resave the file in .rdx format.
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.
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
To create a TDC file:
Open a plain text editor, such as Notepad.
Copy the information from the sample provided below, paste it into your text file, and then specify the
source-charsetvalue. (For a list of encodings, see User-defined Encodings Supported by the Statistical File Connector.)
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.
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.
In certain situations, you might need to delete a shadow extract from your computer. For more information, see Low Disk Space because of TTDE Files in the Tableau Knowledge Base.
- Set Up Data Sources – Add more data to this data source or prepare your data before you analyze it.
- Build Charts and Analyze Data – Begin your data analysis.