Reading SAS (*.sas7bdat) Files In Power BI

Since Power BI does not have a native connector to SAS yet I decided to write this blog and walk you through using R to read data from your *.sas7bdat files.

I will assume that the reader does not have R installed so I will walk you through all the steps necessary to get this going.

Step 1 – Install R

You can follow this link and then click on Download R link. The executable will give you an option to install both 32 and 64 bit binaries so please make sure that you match it to your version of Power BI Desktop

Step 2 – Make sure R is enabled in Power BI Desktop

After R has been installed, launch Power BI Desktop and click on File->Options and Settings->Options->R Scripting and make sure that Detected R home directories is populated with the path of your R installation.

Step 3 – Install sas7bdat R library

Launch the R GUI. In my Windows 10 laptop I type MRO in the search box and the R GUI executable pops up

At the command prompt type: install.packages(“sas7bdat”)

If you are connected to the internet the library will be installed and your screen will look like the following:

Step 4 – Read in your file

Now we are ready to connect Power BI Desktop to you file. Click on Get Data->More->R Script

Then paste the following R script into the window (replace my path to the file with your own)



And then click OK (please make sure that your double quotes are in fact double quote)

In the Navigator window select Input and click Edit

You now should be taken to the Power Query window where you can do all necessary transformations

Please note, that SAS dates may come in as integers so you will need to add 21916 to the number and then convert it to the Date type.

8 thoughts on “Reading SAS (*.sas7bdat) Files In Power BI

  1. I have very huge SAS database, which is update millions of ROWs per day. will BI be able to get the SAS data uploaded?

    1. I think this is less of the function of Power BI and more of the function of the machine that will be running in… Generally speaking, Power BI runs well on if the model is well designed and machine is sized appropriately… I have 1B row models that are very perfomant

  2. Hello!
    I was able to connect with SAS database file. However, when i used the same script for a huge file 11GB, it failed. what is solution? i can’t break the file

  3. Hello this was interesting and it works. I have a lot of sas coding. Is it possible to translate sas code in DAX? Maybe a tool is available? Or maybe is it possible to translate sas code by R in DAX?

  4. I am getting following error.. can you please help?

    We encountered an error while trying to connect.
    Details” “ADO.NET:R script error.
    Loading required package :SAS7bdat
    Error:Unexpected input in “input<-read.Sas7bdat(""
    Execution halted

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s