BookmarkSubscribeRSS Feed
Ivan55Boston
Calcite | Level 5

At my company we have some SAS data sets that we would like to work with in Mathematica and vice versa.  Does anyone have any suggestions on the best way to transfer data between SAS and Mathematica?  Thanks!

4 REPLIES 4
Kurt_Bremser
Super User

Out of experience, I advise any textual file format that both applications can process.

With SAS, this means you can create and read fixed-width columns and any kind of delimited (comma, semicolon, tabs, ...) format. One of these should also work with Mathematica.

From what a quick google search gave me, tab- or comma-separated should be fine.

Reeza
Super User
I'd probably write it to a sqlite db and then read it from there. I hate ensuring types are the same and that's one things that DB are the same....and the CREATE statements from a DESCRIBE statement work well in SQL as well.
HarperCorditt
Calcite | Level 5

SAS typically recommends that you export a SAS data set to another application by first converting the data set into what is known as a "transport file" (which is essentially a text file) that can then (usually) be imported by another application, such as Mathematica.  Mathematica does provide support for reading SAS transport files.  However, this method has its drawbacks, in that the user-defined formatting and other metadata in your SAS data set may not be properly converted.  And if your SAS data set contains dates and/or date-times, those values are likely to cause problems when you try to import the transport file into another application. As an alternative, you might want to consider using a Mathematica add-on called M2SLink.  M2SLink lets you directly import SAS data sets into Mathematica without having to use SAS Transport files.  This way of transferring your SAS data to Mathematica is much faster, all your user formats and metadata are preserved, and your dates and times are automatically converted to be consistent with Mathematica.  M2SLink also allows you to export your Mathematica data directly to a SAS data set.  Here is a link to the M2SLink add-on:

https://www.harpercorditt.com/

Ivan55Boston
Calcite | Level 5

Thank you.  That was very helpful.  It sounds like a seamless way to transfer data.  I will take a look at M2SLink.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 773 views
  • 1 like
  • 4 in conversation