Hi,
Could you please say how sas program can find the path to itself?
I mean the way on a disk where it is kept.
Thank you!
Depending on your environment (batch or workspace server), look at option sysin (you can get it in SQL from DICTIONARY.OPTIONS), &SYSPROCESSNAME, &_SASPROGRAMFILE
Depending on your environment (batch or workspace server), look at option sysin (you can get it in SQL from DICTIONARY.OPTIONS), &SYSPROCESSNAME, &_SASPROGRAMFILE
See this log from Enterprise Guide:
27 %macro grabpathname; 28 %sysget(SAS_EXECFILEPATH) 29 %mend grabpathname; 30 %put %grabpathname; WARNING: The argument to macro function %SYSGET is not defined as a system variable.
and this log from a program run with
sas test.sas
on SAS 9.4M5 on AIX:
1 %macro grabpathname; 2 %sysget(SAS_EXECFILEPATH) 3 %mend grabpathname; 4 %put %grabpathname; WARNING: The argument to macro function %SYSGET is not defined as a system variable.
So you see this is not reliable.
Actually I have used the code (some points are project-specific):
%global pathtofile pathdir; %let pathtofile = %qsubstr(%sysget(SAS_EXECFILEPATH), 1, %length(%sysget(SAS_EXECFILEPATH))-%length(%sysget(SAS_EXECFILEname))); %let code=\code\; %let pathdir =%qsubstr(&pathtofile,1,%index(&pathtofile,&code)); %put &pathdir;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.