BookmarkSubscribeRSS Feed
DMoovendhan
Quartz | Level 8
Hi, I am Using fileexist function to check if the a file is present in Unix location it is working fine, when I execute the code through eg or sas studio, but when I execute it through PC SAS it doesn't recognize the file. When I use PC SAS, I get the program path and derive the file location as in accordance with the actual unix location and set it as a macro variable using SYSLPUT. The libnames gets created perfectly with the path specified. Even if I hard code the correct path it shows the value as 0, that the file is not present I tried mutiple options 1.using filename reference Filename prgconf "&path/config.csv"; %put %sysfunc(fileexist(prgconf); 2.macro variable %put %sysfunc(fileexist(&path/config.csv); 3.direct hardcoded path %put %sysfunc(fileexist(/infra/integ/config.csv); but always the value is 0, how can I check the file presence, is there any other way. Kindly help. Thanks, Moovendhan Devaraj
7 REPLIES 7
ChrisNZ
Tourmaline | Level 20

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?

 

 

DMoovendhan
Quartz | Level 8
Yes, EG and Studio are configured to the UNIX servers... For PC sas I access it through Samba and the execution happens through, signon to remote server and rsubmit.
Tom
Super User Tom
Super User

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.

 

DMoovendhan
Quartz | Level 8
the execution is in remote server through rsubmit after remore signon. The file is present in the remote server.
DMoovendhan
Quartz | Level 8

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

Quentin
Super User

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?

BASUG is hosting free webinars Next up: Jane Eslinger presenting PROC REPORT and the ODS EXCEL destination on Mar 27 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
DMoovendhan
Quartz | Level 8

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;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 1912 views
  • 1 like
  • 4 in conversation