BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
sarafrass
Fluorite | Level 6

Good morning everyone,

 

I'm trying to write a python code for adding a correlation matrix in my SAS analysis.

I wrote it in Jupyter notebook but I'm having issues in connecting it to my SAS.

The code I tried is:

 

import sys
import os
import swat
#Connect to CAS
s = swat.CAS(os.environ['CASUSER'], os.environ['CASPORT'], None, os.environ.get("SAS_VIYA_TOKEN"))
s

 The error I get is:

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-23-06a09f769b64> in <module>
      1 #Connect to CAS
----> 2 s = swat.CAS(os.environ['CASUSER'], os.environ['CASPORT'], None, os.environ.get("SAS_VIYA_TOKEN"))
      3 s

~/opt/anaconda3/lib/python3.8/os.py in __getitem__(self, key)
    673         except KeyError:
    674             # raise KeyError with the original key value
--> 675             raise KeyError(key) from None
    676         return self.decodevalue(value)
    677 

KeyError: 'CASUSER'

 

Thank you so much! 

1 ACCEPTED SOLUTION

Accepted Solutions
2 REPLIES 2
BrunoMueller
SAS Super FREQ

Please have a look at this blog post here https://blogs.sas.com/content/sgf/2020/04/15/getting-started-with-python-integration-to-sas-viya-par... it walks through how to connect to the CAS in SAS Viya for Learners.

SASRobot
Calcite | Level 5

Hi Bruno, thank you!

Would you know how to connect to SASPy from SAS Viya For Learners
I can't find that information anywhere,

Thanks for your orientation,