Please post the whole code you used with the filename pipe.
And keep in mind that the commandline has a different current working directory than the SAS workspace server.
I never use relative paths and always start from a drive or root mount point just in case something like a batch system for some reason has a different execution default locations(different config files can do that).
@fanfanpao wrote:
pls note that i run the code in the batch mode.
Please note that (as an example) sasbatch.sh in Lev1/SASApp/Batchserver calls Lev1/SASApp/ calls appservercontext_env.sh, which explicitly sets the working directory to Lev1/SASApp.
Similar things can (and will) happen in other SAS batch scripts.
Bottom line: NEVER use a relative path unless you have already explicitly set the required current working directory yourself. See Maxim 31.
The execution location is not necessarily that of the program file.
See your config file(s).
Hi @fanfanpao ,
one another thing which came into my mind, if you know the "wanted" starting location in advance, would be use of DLGCDIR() function, to change current working directory, like in the example:
%put *%sysfunc(pathname(WORK))*;
%put *%sysfunc(DLGCDIR(%sysfunc(pathname(WORK))))*;
filename test "."; /*fileref to working dir*/
filename test list;
filename test clear;
which in my case gave:
1 2 %put *%sysfunc(pathname(WORK))*; *C:\SAS_Temporary_Files\_TD4300_H48LBFI12PS0510_* 3 %put *%sysfunc(DLGCDIR(%sysfunc(pathname(WORK))))*; NOTE: The current working directory is now "C:\SAS_Temporary_Files\_TD4300_H48LBFI12PS0510_". *0* 4 5 filename test "."; /*fileref to working dir*/ 6 filename test list; NOTE: Fileref= TEST Physical Name= C:\SAS_Temporary_Files\_TD4300_H48LBFI12PS0510_ 7 filename test clear; NOTE: Fileref TEST has been deassigned.
One disadvantage, it requires SAS 9.4M5 (or 4) to work.
All the best
Bart
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.