Macros for SAS Application Developers
https://github.com/sasjs/core
mf_existds.sas
Go to the documentation of this file.
1 /**
2  @file mf_existds.sas
3  @brief Checks whether a dataset OR a view exists.
4  @details Can be used in open code, eg as follows:
5 
6  %if %mf_existds(libds=work.someview) %then %put yes it does!;
7 
8  NOTE - some databases have case sensitive tables, for instance POSTGRES
9  with the preserve_tab_names=yes libname setting. This may impact
10  expected results (depending on whether you 'expect' the result to be
11  case insensitive in this context!)
12 
13  @param [in] libds library.dataset
14  @return output returns 1 or 0
15 
16  <h4> Related Macros </h4>
17  @li mf_existds.test.sas
18 
19  @warning Untested on tables registered in metadata but not physically present
20  @version 9.2
21  @author Allan Bowe
22 **/
23 
24 %macro mf_existds(libds
25 )/*/STORE SOURCE*/;
26 
27  %if %sysfunc(exist(&libds)) ne 1 & %sysfunc(exist(&libds,VIEW)) ne 1 %then 0;
28  %else 1;
29 
30 %mend mf_existds;