BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Doug____
Pyrite | Level 9

How do I obtain the full path of a SAS program on a Unix-based system (SAS 9.4 TM1S1) automatically?

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

What program?  The program that is currently runnin? How did you submit the program to run?  If you submitted it from the command line then use the value of the SYSIN option. 

 

%let path = %sysfunc(getoption(sysin));

If the file doesn't exist then you might try adding .sas to the end of the value to see if it does.

%if ^%sysfunc(fileexist(&path)) %then %let path = &path..sas;

If you want the FULL path then make a filename and using the PATHNAME() function to get the real filename.

  %let rc = %sysfunc(filename(fileref,&path));
  %let path = %sysfunc(pathname(&fileref));
  %let rc = %sysfunc(filename(fileref));

View solution in original post

3 REPLIES 3
Astounding
PROC Star

As long as you're talking about a batch job, it's straightforward to capture the name as a macro variable:

 

%let path = %sysfunc(getoption(sysin));

 

Once you get into interactive use, you have to consider what you're asking for ... last program brought into the current Program Editor window?

Tom
Super User Tom
Super User

What program?  The program that is currently runnin? How did you submit the program to run?  If you submitted it from the command line then use the value of the SYSIN option. 

 

%let path = %sysfunc(getoption(sysin));

If the file doesn't exist then you might try adding .sas to the end of the value to see if it does.

%if ^%sysfunc(fileexist(&path)) %then %let path = &path..sas;

If you want the FULL path then make a filename and using the PATHNAME() function to get the real filename.

  %let rc = %sysfunc(filename(fileref,&path));
  %let path = %sysfunc(pathname(&fileref));
  %let rc = %sysfunc(filename(fileref));
Doug____
Pyrite | Level 9

The option suggested only renders the word "path" on a remote sumission. Are there other options?

sas-innovate-2024.png

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.

 

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
  • 3 replies
  • 1997 views
  • 0 likes
  • 3 in conversation