It looks like your EG/Studio server is unix, and you have a different unix userid when using the server via a client and when accessing the file from a PC via samba.
Have you checked the authorisations on the file? and on the directory?
Wait, do you actually use /infra/integ/config.csv on the PC?
You mentioned %SYSLPUT so it sounds like you are using SAS/Connect. So make sure you know where you macro code is running.
If you run
%put %sysfunc(fileexist(/infra/integ/config.csv));
on your PC then the answer will always be 0 unless you have a file named
\infra\integ\config.csv
on whatever disk is the current working disk for the Windows process that is running SAS.
When I execute the function file exist with in macro itrs not working, when I execute iot as a separste code it works fine
with in macro
MPRINT(SETUP): rsubmit
NOTE: Remote submit to RMT.__7551 commencing.
MLOGIC(SETUP): %PUT
%sysfunc(fileexist(/interface/3rdparty/arp/test/bards/sandbox_development/hes/mk5592/antibac
terial_antifungal/arw_sas_prgconfig.csv))
0
MPRINT(SETUP): ; x "pwd";
MPRINT(SETUP): endrsubmit;
NOTE: Current working directory is '/dmck1t/3rdparty/tpsandbox'.
1 x "pwd"
1 ! ;
NOTE: Remote submit to RMT.__7551 complete.
As separate code,
1 %put
1 ! %sysfunc(fileexist(/interface/3rdparty/arp/test/bards/sandbox_development/hes/mk5592/antibact
1 ! erial_antifungal/arw_sas_prgconfig.csv));
1
NOTE: Current working directory is '/dmck1t/3rdparty/tpsandbox'.
2 x "pwd"
2 ! ;
NOTE: Remote submit to RMT.__7551 complete.
I have hardcoded the paths in in both the places and its just a copy
That's odd (i.e. doesn't make sense). And I see you have rsubmit involved. Can you try running both tests in a single submission? That is, submit all of the following at once:
%macro test;
%PUT Inside macro: >>%sysfunc(fileexist(/interface/3rdparty/arp/test/bards/sandbox_development/hes/mk5592/antibacterial_antifungal/arw_sas_prgconfig.csv))<<;
%mend test;
%test;
%PUT outside macro: >>%sysfunc(fileexist(/interface/3rdparty/arp/test/bards/sandbox_development/hes/mk5592/antibacterial_antifungal/arw_sas_prgconfig.csv))<<;
From the MLOGIC it looks like maybe you are missing a semicolon at the end of your %PUT statement in the macro?
Thanks For your comment Quentin, in either of the cases it worked.
But your comment helped me to think otherways and to resolve the issue.
My code was like this
%Macro chk1;
%if <condition> %then %do;
Signon remote = <server> User = _prompt_ Pass_prompt_;
rsubmit;
%end;
%IF %sysfunc(fileexist(/interface/3rdparty/arp/test/bards/sandbox_development/hes/mk5592/antibacterial_antifungal/arw_sas_prgconfig.csv)) %then %do;
<Statements>
%end;
%mend;
In this code the macro was executing in the local system and the sas codes were executing in the remote system, so during the execution fileexist was executing in the local machine and so it didn't find the file present.
I tackled the issue by creating a submacro after the remore login, as below, so the macro gets compiled and executed in the remote
%Macro chk1;
%if <condition> %then %do;
Signon remote = <server> User = _prompt_ Pass_prompt_;
rsubmit;
%end;
%macro rtp1;
%IF %sysfunc(fileexist(/interface/3rdparty/arp/test/bards/sandbox_development/hes/mk5592/antibacterial_antifungal/arw_sas_prgconfig.csv)) %then %do;
<Statements>
%end;
%mend rtp1;
%rtp1;
%mend;
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!
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.