Hi,
Is there anyway to determine the path of SAS executable (SAS.exe) dynamically?
Thanks
If you are running on Windows then you can use %SYSGET() to find the value of SASROOT.
So sas.exe should be at
%let location=%sysget(sasroot)\sas.exe ;
Look at the setting of the option PATH.
%put %sysfunc(getoption(path));
It might look like this: !SASROOT/sasexe
One way to translate !SASROOT into a path is to use it in a FILENAME or LIBNAME statement.
filename x "%sysfunc(getoption(path))";
%put %sysfunc(pathname(x));
Hi Tom,
I have the following paths for %put %sysfunc(getoption(path)) and don't see sasroot.
( "!sasext0\aacomp\sasexe" "!sasext0\statcomp\sasexe"
"!sasext0\core\sasexe" "!sasext0\tablesrvtk\sasexe"
"!sasext0\access\sasexe" "!sasext0\af\sasexe"
"!sasext0\assist\sasexe" "!sasext0\connect\sasexe"
"!sasext0\eis\sasexe" "!sasext0\ets\sasexe"
"!sasext0\fsp\sasexe" "!sasext0\graph\sasexe"
"!sasext0\stat\sasexe" "!sasext0\spdsclient\sasexe"
"!sasext0\aacomp\sasexe" "!sasext0\statcomp\sasexe"
"!sasext0\core\sasexe" "!sasext0\tablesrvtk\sasexe"
"!sasext0\access\sasexe" "!sasext0\af\sasexe"
"!sasext0\assist\sasexe" "!sasext0\connect\sasexe"
"!sasext0\eis\sasexe" "!sasext0\ets\sasexe"
"!sasext0\fsp\sasexe" "!sasext0\graph\sasexe"
"!sasext0\stat\sasexe" "!sasext0\spdsclient\sasexe"
Thanks
If you are running on Windows then you can use %SYSGET() to find the value of SASROOT.
So sas.exe should be at
%let location=%sysget(sasroot)\sas.exe ;
Thanks Tom, this worked
hi ... there must be something shorter than this ...
filename temp temp;
proc printto log=temp;
proc options option=set;
proc printto;
data _null_;
infile temp;
input @ '[SASROOT = ' text $100.;
call symputx('root',scan(text,1,'"'));
run;
%put &root;
C:\SAS_9_3\SASFoundation\9.3
Hi Mike,
I tried this but for some reason it gives me the path of sasext1 instead of sasroot. I tried by reducing the length for the variable text to $50. and seems like thats working but didn't understand why it gives me a different path if length is $100.
Thanks
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.