hello people,
the macro below does not recognize "myinput1" and it only throws an output :"The file myinput1 does not exist"
why? How can fix this? please anyone. Thx
filename myinput1 ftp " 'XYZ.C.M.DATA.XYZZ.G0049V00' " user=** pass=*** host="xyz.com";
%let testfile = myinput1;
%macro findit;
%if %sysfunc(fileexist(&testfile)) %then %do;
%put good;
%end;
%else %put The file &testfile does not exist. ;
%mend;
%findit;
Read the documentation for fileexist():
thanks a lot sir!
So there is no way I can check for existence of file in the mainframe host?
You can only use FILEEXIST to check for the existence of a file that is available locally to SAS, not remotely via an FTP link. You would actually have to try to read the file via FTP to confirm it exists or alternatively a "directory list" - not sure how to do this on a mainframe via FTP.
I'm not sure it will help because you use ftp engine, but you may try:
%macro findit;
%let fid=%sysfunc(fopen(testfile));
%if %eval(&fid) > 0 %then %do;
%put good;
%end;
%else %put Cannot open the file &testfile ;
%mend;
Just tried but not working Shmuel,
Anyway so I guess this is not doable then. Thanks for your help guys
@Tal wrote:
thanks a lot sir!
So there is no way I can check for existence of file in the mainframe host?
Run a directory listing (filename ftp can do this), and check the output.
@Tal wrote:
Sorry i dont know what you mean
Once again, I have to direct you to the SAS documentation:
The first example shows how ro retrieve a directory listing from a remote ftp server.
While reading this infile, you can check the input line (_infile_) for the filename with the index() function.
Note that I referenced a 9.2 page, as the 9.4 online documentation seems to be mis-organized at the moment.
Edit: Link for the 9.4 documentation of the FILENAME statement, FTP method:
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.