08-22-2014 03:03 AM
I am trying to implement a line code for stop de program when the file does not exits in the ftp server but without sucess.
Sometimes I connect to an ftp for a file and it's no there anymore.
Sas write an Error in the log but continue processing, my intention is to stop the code after this error ocurred.
here were are an example of my code
FILENAME aaa ftp "ftp path." user="&user." pass="&pass." debug
host='nameofthehost' rcmd='site rdw' cd='..';
data test (compress = binary);
infile aaa missover lrecl=1420 recfm=F;
@1 wwww $EBCDIC8.
@10 eeeee $EBCDIC39.
@51 rrrrrr $EBCDIC4.
@56 ttttt $EBCDIC39.
if &syserr. ne 0 then abort;
How can I achieve my purpose?
08-22-2014 03:07 AM
Use the LS or LIST option on the FTP infile to get a list of files in the folder
Only if it's there should you try to read it.
that option will be found on the FTP filename statement - probably not on INFILE
08-22-2014 03:29 AM
The option LIST is not working for me
'Invalid Reply received for the STOR command..'
and the line of code if &syserr. ne 0 then abort; it doesn't anyting because the code continue to run
08-22-2014 04:13 AM
I have no access to these options, In any case my intention is not to see the files that are in the server but it stop the program for prevent to run without observations due to not to download the data from the server.
08-22-2014 04:16 AM
SAS(R) 9.4 Language Reference: Concepts, Third Edition Error processing is a long long story.
The &syserr and &sasrc are macro-variables these are set after a proc/datstep processing.
Builing logic on macro-variables is macroprocessing in this case to be implemented after the datastep processing.
There are differences in the error-condition follow up.
In interactive mode it can proceed a lot, in batch mode it is more often halting. When you are using interactive mode expect the need for manual intervention.
You can delete the dataset test and after the datastep has run verify the number of obs aside other things (macro) to do follow up as you like.