Hello
I added the MAS_PYPATH to Win11 env. variables and now I get a new error:
ERROR: Module 'py' failed to compile in user context 'CMP User Thread'.
NOTE: Module 'py' compilation errors:
ERROR: MAS_M2PATH environment variable is
undefined.
ERROR: tkmaspyPublish encountered a failure in tkmaspyConnect, rc=0x803FC26A.
ERROR: masPublish encountered a failure.
ERROR: Foreign Language Compilation messages:
ERROR: Python compile: ERROR: MAS_M2PATH environment variable is undefined.
ERROR: Python compile: ERROR: tkmaspyPublish encountered a failure in tkmaspyConnect,
rc=0x803FC26A.
ERROR: Unable to publish program for foreign language execution.
ERROR: Error reported in function 'python:PUBLISH' in statement number 4 at line 15 column 1.
However, I can not find any reference in documentation to this env. variable ( MAS_M2PATH)
Hello @TimBedsted , @nstdt
Please have a look at the post by @ChrisHemedinger at Re: Executing python code from SAS Environment - SAS Support Communities
Please note that the value of MAS_M2PATH should represent the actual path of mas2py.py .
Similarly, the value of MAS_PYPATH should be the actual path of python executable.
If you still have issue, you can try appending the path of python.exe and mas2py.py to the system PATH variable (i.e., environment variable) OR add the following to the SAS EG options
options SET=PATH=SYSGET(PATH):[path of python.exe];[path of mas2py.py];
You must set the environment variables in the SAS startup script, not in a separate cmd window.
This is what @Kurt_Bremser was talking about
1.Create a Windows batch script in a desired directory (pyfromsas.bat)
2.Inside that pyfromsas.bat file, add the following lines
REM echo off
set MAS_M2PATH=<C:\Program Files\SASHome\SASFoundation\9.4>\tkmas\sasmisc\mas2py.py
set MAS_PYPATH=C:\<InstallationPath>\python.exe
"<C:\Program Files\SASHome\SASFoundation\9.4>\sas.exe" -CONFIG "<C:\Program Files\SASHome\SASFoundation\9.4>\nls\en\sasv9.cfg“
3.Save the pyfromsas.bat
4.Run the script
C:\> <path>\pyfromsas.bat
Note: Change the <C:\Program Files\SASHome\SASFoundation\9.4> to match the installation directory of the SAS software on your machine.
Hope this helps,
Ahmed
Thanks Ahmed, I will try out your suggestions soon. I had some questions though -
1.
When you say : 1.Create a Windows batch script in a desired directory (pyfromsas.bat) - what is this desired directory? Where do I put the pyfromsas.bat file? Does it matter or can it be anywhere?
2. When you say:
Change the <C:\Program Files\SASHome\SASFoundation\9.4>to match the installation directory of the SAS software on your machine. :\Program Files\SASHome\SASFoundation\9.4 actually is part of the installation path, because my version of SAS9.4 has been installed locally on my own laptop. So I don't need to change that, do I?
Here is where Windos search bar locates SAS on my laptop:
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\SAS
Thank you
The SAS Users Group for Administrators (SUGA) is open to all SAS administrators and architects who install, update, manage or maintain a SAS deployment.
SAS technical trainer Erin Winters shows you how to explore assets, create new data discovery agents, schedule data discovery agents, and much more.
Find more tutorials on the SAS Users YouTube channel.