Production Ready 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 libds library.dataset
14  @return output returns 1 or 0
15  @warning Untested on tables registered in metadata but not physically present
16  @version 9.2
17  @author Allan Bowe
18 **/
19 
20 %macro mf_existds(libds
21 )/*/STORE SOURCE*/;
22 
23  %if %sysfunc(exist(&libds)) ne 1 & %sysfunc(exist(&libds,VIEW)) ne 1 %then 0;
24  %else 1;
25 
26 %mend;