If error "physical file doesnt exist" then...

Reply
New Contributor
Posts: 3

If error "physical file doesnt exist" then...

Hi,

 

 

I have a macro which checks if the file exist and if it doesnt i want to append a different data set to another set.

 

So I have an idea to use syserr option

 

%if &syserr > 1 %then %do ;

proc append base=base.data data=test_data  force;

%end;

 

but I want to specify that if concrete error occurs "physical file doesnt exist" then the proc append will work.

 

Is there a such possibility ?

Esteemed Advisor
Posts: 6,737

Re: If error "physical file doesnt exist" then...

Why not use the fexist() function first to determine if the file exists, and use that as condition?

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
New Contributor
Posts: 3

Re: If error "physical file doesnt exist" then...

[ Edited ]

i had a problem with fexist, but  i fixed it so it's ok.

 

but i'm curious, is there a possibility to determine condtional logic based on a specified error ?

Esteemed Advisor
Posts: 6,737

Re: If error "physical file doesnt exist" then...

[ Edited ]

If you have a code that identifies a specific error, you can use that. But the documentation for &syserr does not show a particular code for "physical file does not exist". So I recommend to check with fexist, as you otherwise might do something unexpected when another error occurs.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Valued Guide
Posts: 2,174

Re: If error "physical file doesnt exist" then...

and FILEEXIST()
Ask a Question
Discussion stats
  • 4 replies
  • 106 views
  • 2 likes
  • 3 in conversation