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-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
  • 5 replies
  • 1553 views
  • 0 likes
  • 3 in conversation