BookmarkSubscribeRSS Feed
SergioSanchez
Calcite | Level 5

Hi all

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;

input

    @1 wwww $EBCDIC8.

    @10 eeeee $EBCDIC39.

    @51 rrrrrr $EBCDIC4.

    @56 ttttt $EBCDIC39.

if &syserr. ne 0 then abort;

run;

How can I achieve my purpose?

Thanks

5 REPLIES 5
Peter_C
Rhodochrosite | Level 12

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

SergioSanchez
Calcite | Level 5

Thanks Peter

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 Smiley Sad

Peter_C
Rhodochrosite | Level 12

Perhaps your FTP server does not understand command LIST.

Have you tried LS?

Please show the code and log

SergioSanchez
Calcite | Level 5

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.

jakarman
Barite | Level 11

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. 

---->-- ja karman --<-----

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1808 views
  • 0 likes
  • 3 in conversation