SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sasjourney
Calcite | Level 5

Hi,

Is there anyway to determine the path of SAS executable (SAS.exe) dynamically?

Thanks


1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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 ;

View solution in original post

6 REPLIES 6
Tom
Super User Tom
Super User

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));

sasjourney
Calcite | Level 5

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

Tom
Super User Tom
Super User

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 ;

sasjourney
Calcite | Level 5

Thanks Tom, this worked

MikeZdeb
Rhodochrosite | Level 12

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

sasjourney
Calcite | Level 5

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

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 13708 views
  • 0 likes
  • 3 in conversation