Pages

Saturday, August 10, 2013

Widgets

Check for the existence of a dataset

So often there are so many datasets in a library that it becomes impossible to look out for a particular dataset. To help find a dataset, we can use a simple DATA step function for checking the existence if the dataset. The function is EXIST. Here is the macro to achieve this.


 %MACRO DATA_EXIST(INPUT);
  %IF %SYSFUNC(EXIST(&INPUT)) %THEN %DO;
  %PUT DATA EXISTS;
  %END;
  %ELSE %DO;
  %PUT DATA DOES NOT EXISTS;
  %END;
 %MEND;
 
 %DATA_EXIST(SASUSER.TEST);
Further simplification can be done by:
%MACRO D_EXIST(INPUT);
 %SYSFUNC(EXIST(&INPUT))
%MEND D_EXIST;
The macro %D_EXIST could be called from within an expression.
 %IF %D_EXIST(SASHELP.CLASS) %THEN %DO;

No comments:

Post a Comment