DSN In Directory

Making programs sensitive to data available is an important technique. Allowing the program to finish and report on any problems makes problem-solving easer. Allocating data sets with SAS code instead of JCL provides the user with tools to prevent abnormal terminations. The SAS macro DSNEXST will determine if the data set is in the catalog. It set the SAS macro variable SYSDEXST to 1 if it is in the catalog or 0 if it is not. The DSNINDIR macro provides messages to the SAS log indicating the availability of the data set.

DSNINDIR macro

%MACRO DSNINDIR(DSN); /* IS DATASET READY? */
 DSNEXST "&DSN" ; 
 %IF &SYSDEXST %THEN %DO; /* YES IT IS */ 
  %PUT %STR(----------->DSN=&DSN SYSDEXST=&SYSDEXST); 
 %END ; 
 %ELSE %DO; /* NO IT IS NOT */
  %PUT %STR(----------->DATASET &DSN DOES NOT EXIST); 
  %PUT %STR(----------->DSN=&DSN SYSDEXST=&SYSDEXST); 
 RUN ; 
 %END ; 
 %MEND; 
 RUN ;