Since you can no longer use "." to implicitly reference the current working directory for batch grid jobs, try this:
%global pwd cwd;
%macro wd;
filename envcmd pipe 'set | egrep "PWD=|LS_SUBCWD="' lrecl=1024;
data env;
length var $9 val $200;
infile envcmd dlm='=' missover;
input var $ val $;
if val ^= ''
then do;
if var = 'PWD'
then do;
pwd = val;
put pwd=;
call symput('pwd',strip(val));
end;
if var = 'LS_SUBCWD'
then do;
cwd = val;
put cwd=;
call symput('cwd',strip(val));
end;
end;
run;
%if %superq(cwd) ^=
%then %let pwd = &cwd.;
%put pwd=&pwd.;
libname pwd "&pwd.";
libname here "&pwd.";
%mend wd;
%wd;
* End of Macro Include *;
Example output:
(batch grid launch from command-line with sasgsub)
CWD=/path/where/sas/code/resides
PWD=/sas/config/compute/Lev1/SASApp
(batch grid launch from EG with XCMD and sasgsub)
CWD=/path/to/EG/home/where/sas/code/resides
PWD=/sas/config/compute/Lev1/SASApp
(interactive grid launch from EG)
CWD=/path/to/UNIX/home
PWD=/sas/config/compute/Lev1/SASApp
In the first two cases, we want the value of CWD to overwrite PWD and be captured in a macro-variable for assigning librefs, filerefs, etc. For the third case, it's not really helpful as neither path makes sense for assignment. This is really designed for capturing paths in batch grid jobs where the current working directory changes.
In what context do those last two lines work? In another macro somewhere? Or is your entire example meant to be enclosed in a macro?
@ChrisHemedinger, I updated my original post that hopefully answers your questions. I'd also be happy to discuss this more at GF.
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.
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.