DATA Step, Macro, Functions and more

How sas program can find the path to itself

Accepted Solution Solved
Reply
Regular Contributor
Posts: 214
Accepted Solution

How sas program can find the path to itself

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!


Accepted Solutions
Solution
‎03-30-2018 08:24 AM
Super User
Posts: 10,574

Re: How sas program can find the path to itself

Posted in reply to DmytroYermak

Depending on your environment (batch or workspace server), look at option sysin (you can get it in SQL from DICTIONARY.OPTIONS), &SYSPROCESSNAME, &_SASPROGRAMFILE

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code

View solution in original post


All Replies
Solution
‎03-30-2018 08:24 AM
Super User
Posts: 10,574

Re: How sas program can find the path to itself

Posted in reply to DmytroYermak

Depending on your environment (batch or workspace server), look at option sysin (you can get it in SQL from DICTIONARY.OPTIONS), &SYSPROCESSNAME, &_SASPROGRAMFILE

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Contributor
Posts: 72

Re: How sas program can find the path to itself

Posted in reply to DmytroYermak
Please try below code , it gets the path name.


%macro grabpathname;
%sysget(SAS_EXECFILEPATH)
%mend grabpathname;
%put %grabpathname;
Super User
Posts: 10,574

Re: How sas program can find the path to itself

Posted in reply to DR_Majeti

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.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Regular Contributor
Posts: 214

Re: How sas program can find the path to itself

Posted in reply to KurtBremser

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;
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 144 views
  • 0 likes
  • 3 in conversation