BookmarkSubscribeRSS Feed
prad001
Obsidian | Level 7

Hello All,

I am using SAS on Windows connected to remote SAS Server installed on Azure(Windows). I use SAS 9.4M3. 

 

I have a situation, I will try my best to explain the situation. Please let me know your thoughts and suggestions.

 

We have encrypted data in the database. The encryption is being done by the third party tool. Now the end user wants to decrypt the data which is accessed via SAS Enterprise Guide and Tableau.

 

We have successfully implemented the Tableau Part using the below script.  

 

 

def var_decryption(inputList)
import azure.common.credentials
import azure.keyvault.secrets
import azure.identity
keyvalultCredentials = *******
headers = ****
body = ****
url = ****
response = requests.post(url, data=body, headers)
jsonData=response.json()
accessToken = jsonData["access_token"]

variable = '~!'.join([str(item) for item in inputlist])
task = {'plaintext': variable}
header = {
'accesstoken' : accesstoken
}
resp = request.post('http://URL', json=task , headers = header,verify=False)
resTempList = resp.text.split('!')
return resTempList
#for deploying on Tableau server we use the below line
client.deploy('var_decryption', var_decryption, 'decrypt text via api', override=True)

#from Tableau we call it with the below command
#SCRIPT_STR("return tabpy.query('var_decryption', variable1)['response']",ATTR(varaible2]))
`

So., the above python function is deployed on the Tableau server using TabPy component using client.deploy(https://tableau.github.io/TabPy/docs/tabpy-tools.html). The last line in the above code is how we call & pass the encrypted value and the response is passed on after decryption. Calling the API, authentication etc happens with this script. It is running for each value on reading of the data. 

 

 

Now., I have to do the same process using SAS EG. Like Tableau we cannot deploy Python function on the SAS server., I tried to use Proc FCMP but failed because the our version of SAS does not support PROC FCMP.

 

Hence, I am left with running the above python script using X Command but even that is not working because I am unable to figure out how to pass the variable, dataset name and the path of the dataset (With the script above it only passes variable name).

 

 

The important points to mention here is, the end user wants the data to be decrypted after executing a query in SAS EG.., the API is treated pretty much like black box because that is working and the business does not want to change anything related to it. Hence we have to call the API as is..! 

 

Example:
Data New(var1,var2);
Set db.table;
Run;

The above query is ran from SAS EG Where var1 is encrypted and hence we need to decrypt the value of that using the python script.

 

 

Can you please help me with the best solution for this process.

 

Thank you so much in advance. And please let me know if I am not clear in any aspect.

 

 

 

 

5 REPLIES 5
SASKiwi
PROC Star

The problem is your SAS data resides on the remote SAS server only so the only way to decrypt it would be to also run the decryption process there. What version of SAS do you have? It is possible to run Python in some older SAS versions if you have SAS/IML.

prad001
Obsidian | Level 7
Hi SASKiwi.,
I have 9.4M3. And I do not have SAS/IML as well.
SASKiwi
PROC Star

Have a look at this Communities post about running R and Python with or without SAS/IML: Solved: How to RUN R or Python in SAS - SAS Support Communities

 

It does mean Python will need to be installed on your SAS server. Have you discussed this with your SAS administrator?

prad001
Obsidian | Level 7
I have made SAS Admins install Python on the server. Running python script is not an issue. I could test and run a sample program and it is working fine.
SASKiwi
PROC Star

I suggest you check out the code examples in the link I sent you. @rogerjdeangelis may be able to help so I'm linking him in.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 2052 views
  • 1 like
  • 2 in conversation