To load a sas table into Python is easy with the pandas module in Python, i.e. pd.read_sas. For documentation of that, see this link: https://www.marsja.se/how-to-read-sas-files-in-python-with-pandas/
Now my problem is the following:
I have SAS tables that I want to read into Python, this is easily done with pd.read_sas.
Then I will do some work in Python and would finally like to export the data frame to a Sas file directly, is this possible to do?
Note: I am aware of that the latest version of VIYA can handle Python code inside a SAS session but this is not relevant since in my organization we will not have the latest VIYA version.
Edit: Writing proc setinit; run;
I get the following: Current version: 9.04.01M5P091317
I know SAS can import R dataframe by IML. @Rick_SAS wrote several blog about it .
Can you change Python into R ?
You can use the SASPy package to connect to SAS from Python. For an introduction, see "How to code in Python with SAS 9.4."
For more details, including how to transfer data from a Pandas data frame into a SAS data set, see Foreman (2018)
"SAS and Python: The Perfect Partners in Crime"
Thanks alot @Rick_SAS, I will read out on all of that.
At a first sight, I must have SAS 9.4 whereas my version is: Current version: 9.04.01M5P091317 . So this will not work
Do you spontaneously know wether it is possible to (without connecting to SAS or anything) just export a pandas dataframe to a SAS table analogously as I easily could export a dataframe to a CSV or Excel file?
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!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.