saspy | Python interface module to the SAS System | Code Editor library
kandi X-RAY | saspy Summary
kandi X-RAY | saspy Summary
This module provides interfaces between Python and SAS. This module enables a Python developer to create mixed Python/SAS workflows to leverage the powers of both SAS and Python, by connecting a Python process to any of a variety of SAS deployments, where it will run SAS code. The SAS code is generated by the SASPy object and methods or explicitly user written. Results from SAS are returned as text, HTML5 documents (via SAS ODS), or as Pandas Data Frames. This module supports running analytics and returning the resulting graphics and result data to the Python process. It can convert data representations between SAS Data Sets and Pandas Data Frames. This module has multiple access methods which allow it to connect to local or remote Linux SAS, IOM SAS on Windows, Linux (Including Grid Manager), or MVS, and local PC SAS. It can run within various Notebooks platforms, or IDE's/UI's or in interactive line mode Python or in Python batch scripts. It is expected that the user community can, and will, contribute enhancements.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Convert pandas dataframe to sasdata
- Convert Pandas DataFrame to SASdata
- Convert a Pandas DataFrame to a SASdata object
- Appends data to the SASdata object
- Start the socket
- Return a Pandas DataFrame
- Return information about the results
- Check for errors in log
- Process interupt
- Return a list of directories for a directory
- Lists all available tables
- Convert a set of Docs to Markdown documentation
- Check if the given libref exists
- Convert SAS data to DataFrame
- Submit code to LST
- Write a Pandas DataFrame to a SAS Data Table
- Initialize the session
- Upload file to remote host
- Return the connection id
- Convert a Pandas DataFrame to SASdata format
- Return the PID of the SAS process
- Convert a pandas DataFrame to a Pandas DataFrame
- Generate code for code
- Impute the SAS data
- Download file from remote host
- Download a file
saspy Key Features
saspy Examples and Code Snippets
Community Discussions
Trending Discussions on saspy
QUESTION
While using SaSPy, how can I find where the library RWORK is located ?
I tried sas.dirlist() but without being able to find anything.
It might be due to remote access?
Below is my setup connexion
...ANSWER
Answered 2022-Mar-14 at 15:50I suspect SASPy can't see the remote as you say. You can certainly find out by running code in SAS, just run this inside the rsubmit block:
QUESTION
I am trying to run a SAS program on linux using python. This server has SAS installed (version 9.4). And python version I have is 3.7.3.
I learned there is a library saspy which I could use however my project does not have access to this library. So, I found another alternative, my intension is to invoke the sas program in python and get the return code when it is successfully completed. This Sas program usually takes 1hr to complete.
So, I would like to use the return code when it is successful and later would like to notify myself through an email. I wrote the below code (sample) and I unable to make the subprocess work ? Any help is appreciated. Thanks
...ANSWER
Answered 2022-Jan-26 at 16:56subprocess.call is an older method of doing this, but it should work; per the documentation, you need to use the returncode attribute to access the return code.
You may be better off using subprocess.run(), which returns a CompletedProcess instance.
Either way, you probably should ensure that your shell command (which looks like a .bat file) actually returns the value from the SAS execution. If it uses call
, for example (in Windows batch script), it may actually be running SAS in the background - which is consistent with what you're describing here, and also consistent with the filename (BGsas
). You may want to use a different script to launch SAS in the foreground.
QUESTION
Does anyone has used the file_delete() method of SASpy? I'm trying to delete a file in SAS Server side using this method but I was unable to make it works.
...ANSWER
Answered 2021-Apr-22 at 19:13I just tested this. In 3.3.7 this is not available; in 3.6.6 it is available. I'm not sure exactly what version it was added in (most likely 3.5.0, that seemed to be a big update), but most likely you just need to run:
QUESTION
I am trying to read SQL query output and create a SAS dataset using Python pandas. My SQL query is executing properly but only importing column names into SAS dataset due to data shifting. It is an encoding issue and I wanted some guidance on how to fix this. Below is my code:
...ANSWER
Answered 2021-Jan-20 at 02:33First, I'm going to guess that you might have some embedded newline characters in the data.
See this github issue which has the same error message as you have. (Also note the detail in the initial post - this is about what your initial post should have looked like!)
If you have at least SASPy version 3.1.4, you should have an option embedded_newlines=true
you can set, the example code:
sas.dataframe2sasdata(df=problematic_data,table='via_sas_test_prob',libref='OUT', embedded_newlines=True)
(that is an alias for df2sd
, by the way). Hopefully that works in Viya; SASPy mostly runs base (MVA) SAS, so I don't know what things are different in Viya (and don't have Viya). If you don't have 3.1.4 or newer, then update your SASPy.
Another option would be to remove the newline (\n
) characters in Python before transferring the data over. That's what the user in the github issue does.
Second, if you're running things in Viya, consider using python-SWAT, which is the SAS Viya scripting library in Python. It submits things as CAS actions, which might be better for you.
Finally, a third option would be to run the database connection piece in SAS. Unless you didn't license ACCESS to ODBC, of course, but if you do license that, then I'd consider moving that piece to SAS and just telling SAS to input the file itself.
QUESTION
Please see the image below for my SAS Server Layout. I would like to pull the top table 2020_01_SETTLEMENTS
and place it into a Python data frame. I have successfully established connection between Python and the SAS Server. I have the following code below but I believe where I am going wrong is in the LIBREF
part of the sasdata2dataframe
function. I have listed the error message below as well. Much appreciated to anyone who can tell me where I went wrong. I've also linked the reference material to this function here:
https://sassoftware.github.io/saspy/api.html
Code:
...ANSWER
Answered 2020-Aug-11 at 21:53Although as it is not specified in the manual, I ended up using the following code instead and it worked. I just changed table: str = '2020_01_SETTLEMENTS'
to table='2020_01_SETTLEMENTS'
QUESTION
For normal SAS software, one can use the Python package SASPy
inorder to connect to a SAS server, retrieve data and manipulate the data with Python code. However, this package does not seem to work for SAS EG. Does anyone know how to import data from SAS EG servers in a Python IDE?
For example:
...ANSWER
Answered 2020-Aug-10 at 21:50This hyperlinked document was very helpful in allowing me to figure this out. It required two files. One cfg
file to host the server info. And another file to create a SASsession
that referenced the cfg
file. For the Windows IOM server I used the code below:
https://sassoftware.github.io/saspy/install.html#choosing-an-access-method
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install saspy
All of the doc, including install and configuration information can be found at sassoftware.github.io/saspy. Also, example Notebooks and use cases can be found at sassoftware/saspy-examples.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page