BookmarkSubscribeRSS Feed
Raj123
Calcite | Level 5

Hi,

 

i have PC sas open(interactive) and signed into unix server(remote). i want to find the path of my current program. how can i achieve this.

i know that in windows we can use %sysget(SAS_EXECFILEPATH)  but the system macro variable is not present in remote unix session. 

 

Scenario: what is needed.

rsubmit;

   create a macro variable that contains the path of the my current SAS program that i have it open in PC SAS Interactive.

 

endrsubmit;

 

so far what i tried.

I Tried looking through this community but none of the suggestions seems to work. 

eg: https://communities.sas.com/t5/SAS-Communities-Library/Find-current-directory-path/ta-p/485785.

%macro curdir;
%local fr rc curdir;

%let rc = %sysfunc(filename(fr,.));
%let curdir = %sysfunc(pathname(&fr));
%let rc = %sysfunc(filename(fr));

%put &curdir;

%mend curdir;
%curdir;

 

this suggestion works only in WINDOWS but not in Unix it give me a value of --> "/home/userid" . in windows from sashelp.vextfl we can find the path of program but not able to in unix

 

- Raj

4 REPLIES 4
Raj123
Calcite | Level 5

Thanks Kurt. but my situation is little different. I will try to explain. 

we have a start up program containing librefs that i am trying to automate so that user can have all the libnames auto set-up in windows or remote. i need the path of the program for this.

 

Example: have only one program that works either when submitting the program remotely or on PC.

 

i was thinking to end the rsubmit if the environment is remote and get the path locally and then move back to remote(using %syslput) but i get an error after endrsubmit(below) because it goes into windows environment and there is %end without corresponding %do;

 

 

%macro x;
  %if &sysscp ne WIN %then %do;
        endrsubmit;
   %end;
%mend;
%x;

 

Any suggestions. Thanks! 

Raj

Tom
Super User Tom
Super User

That sounds like an even more complex problem. Getting macro execution properly synched with remote/local combined execution modes can be a head scrambler.  Also trying to use the new %SYSLPUT macro statement can get confused by macros.  I have found it is better to use the method used by the %SYSLPUT() macro that SAS provided with SAS 6.12 and early versions instead.  I have a copy here (https://github.com/sasutils/macros/blob/master/syslput612.sas) that has been renamed as %SYSLPUT612() to avoid the conflict with the new statement.

Tom
Super User Tom
Super User

If you are running interactively then the best you can do is a guess about what program you are running.

If you are using the "Enhanced" editor that is available in DMS running on Windows then your code that checks the environment variable SAS_EXECFILEPATH might work. But it is just the name that the enhanced thinks is the name of the file it is editing.  In reality the text that is currently in the editor (and especially which of those lines you submitted to run) might have little to do with what is saved now (or later) into the file that environment variable points to at the time your SAS code runs.

That said it needs to be checked in the local (windows) SAS session and then passed to the remote (unix) session.

* Start remote session ;
signon;
* Set remote session macro variable with value of local environment variable ;
%syslput pc_filename=%quote(%sysget(SAS_EXECFILEPATH));

rsubmit;
... use &PC_FILENAME as the name of the current SAS program ...
endrsubmit;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

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