I'm working on a data set (PSID) that gives data in a SAS format (a .txt and another file containing instructions to interpret the data). I cannot find anything in Python to read this type of data.
Does anyone know of a pre-existing module/script to read SAS data?
Edit (added from a comment to an answer): The data is in ascii/text and the start of a row of data looks like this:
3 10 1015000 150013200 00 002500 00 00
Python is a powerful tool for working with data, and makes the perfect partner to SAS to process data, particularly data that is obtained from online sources where programmers have developed open source Python code to connect to published APIs.
In addition, Python provides useful modules to enable users to access and handle SAS datasets and utilize SAS modules from Python via SASPy modules (Nakajima 2018). These functionalities are very useful for users to learn and utilize both the functionalities of SAS and Python to analyze the data more efficiently.
As of version 17, Pandas now supports reading sas files with the .xpt file extension. See this link to pandas documentation for additional details.
df = pd.read_sas('sas_xport.xpt')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With