BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
DmytroYermak
Lapis Lazuli | Level 10

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!

1 ACCEPTED SOLUTION

Accepted Solutions
4 REPLIES 4
Kurt_Bremser
Super User

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

DR_Majeti
Quartz | Level 8
Please try below code , it gets the path name.


%macro grabpathname;
%sysget(SAS_EXECFILEPATH)
%mend grabpathname;
%put %grabpathname;
Kurt_Bremser
Super User

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.

DmytroYermak
Lapis Lazuli | Level 10

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;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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