SAS_EXECFILENAME and SAS_EXECPATHNAME into UNIX environment

Reply
Occasional Contributor
Posts: 5

SAS_EXECFILENAME and SAS_EXECPATHNAME into UNIX environment


Could you automatically retrieve the name and the path of the current program which is running into UNIX environment?

Super User
Posts: 5,254

Re: SAS_EXECFILENAME and SAS_EXECPATHNAME into UNIX environment

Please tell us which type of programs you mean, and how are they being executed? Batch, Workspace Server, interactively etc...

Data never sleeps
Occasional Contributor
Posts: 5

Re: SAS_EXECFILENAME and SAS_EXECPATHNAME into UNIX environment

I mean a job SAS iinto Data Integration Studio or a SAS code that runs on the client SAS Base 9.3. I had just try the following code:

%macro name_pfad;

%if &SYSSCP = WIN %then %let TRENNER=\;
%else %if &SYSSCP = OS %then %let TRENNER=.;
%else %let TRENNER=/;


proc sql noprint;
select scan(xpath,-1,"&TRENNER.") into Smiley Tonguerogname from sashelp.vextfl
where upcase(xpath) like '%.SAS';
quit;

%put &progname;

/* oder */

data _null_;
set sashelp.vextfl(where=(upcase(xpath) like '%.SAS'));
call symput('program', scan(xpath,-1,"&TRENNER."));
run;

%put &program;

/* Pfad: */

proc sql noprint;
select xpath into Smiley Tonguefad
from sashelp.vextfl where upcase(xpath) like '%.SAS';
quit;

%put &pfad;

/* or */

data _null_;
set sashelp.vextfl
(where=(upcase(xpath) like '%.SAS'));
call symput('pfad', xpath);
run;

%put &pfad;
%mend name_pfad;
%name_pfad;

This code find only the standard path for autoexec.sas

Contributor
Posts: 29

Re: SAS_EXECFILENAME and SAS_EXECPATHNAME into UNIX environment

I'm not exactly sure what you are trying to do, as I have no entries in my vextfl table that match %.SAS

However, it looks to me like every time you call symput in the data steps you will overwrite the variable you are creating, so at the end of the data step you will only ever get 1 value to use in your %put statement.

If you run this as a test you may at least see in the log what your matches are (or create a data set instead of using data _null_):

data _null_;
set sashelp.vextfl
(where=(upcase(xpath) like '%.SAS'));
put fileref xpath;

run;

Occasional Contributor
Posts: 5

Re: SAS_EXECFILENAME and SAS_EXECPATHNAME into UNIX environment

The result is the following:

#LN00005 /sas9.3/sas/sasperm/meta3/Lev1/SASApp/WorkspaceServer/autoexec.sas

autoexec into the workspaceServer, instead I would like to have the path of program which is runs now (for example c:\xxxx\program1.sas)

Contributor
Posts: 29

Re: SAS_EXECFILENAME and SAS_EXECPATHNAME into UNIX environment

I found this code in the SAS Help (searched on SAS_EXECFILEPATH):

%let execpath=" ";
%macro setexecpath;
   %let execpath=%sysfunc(GetOption(SYSIN));
   %if %length(&execpath)=0
      %then %let execpath=%sysget(SAS_EXECFILEPATH);
%mend setexecpath;

%setexecpath;
%put "execpath=&execpath";

This code works if I run it on my local Windows SAS session, and it works if I run it from the command line on my AIX server.

However, if I remote submit this code from SAS on Windows to my AIX server it does not work.

So, the answer to your problem may depend on how you submit your code. If you are starting from Windows, and submitting it remotely, then you may need to get the execpath from the SAS_EXECFILEPATH variable before you submit the rest of the code to unix. You could use %syslput to copy the value of execpath to the remote session.

Does that help?

Ask a Question
Discussion stats
  • 5 replies
  • 997 views
  • 0 likes
  • 3 in conversation