29 %MACRO assertRowExpression(i_libref         = 
 
   32                           ,i_desc           = Check 
if all observations meet the where expression
 
   39    %IF &g_inTestcase EQ 1 %THEN %DO;
 
   42    %ELSE %IF &g_inTestcase NE 2 %THEN %DO;
 
   43       %PUT &g_error.(SASUNIT): assert must be called after initTestcase;
 
   47    %LOCAL l_dsname l_result l_actual l_errmsg l_nobs l_casid l_tstid l_path;
 
   48    %LET l_dsname =%sysfunc(catx(., &i_libref., &i_memname.));
 
   52    %*************************************************************;
 
   53    %*** Check preconditions                                   ***;
 
   54    %*************************************************************;
 
   55    %*** check 
for valid libref and existence of data set***;
 
   56    %IF (%sysfunc (libref (&i_libref.)) NE 0) %THEN %DO;
 
   58       %LET l_errmsg =Libref &i_libref. is not valid!;
 
   61    %IF (%sysfunc(exist(&l_dsname.)) EQ 0) %THEN %DO;
 
   63       %LET l_errmsg =Dataset &l_dsname. does not exist!;
 
   66    %IF (%upcase (&o_maxReportObs.) ne MAX) %THEN %DO;
 
   68          num=input (symget (
"o_maxReportObs"),??8.);
 
   69          if (num <= 0) then 
do;
 
   70             PUT 
"&G_WARNING.(SASUNIT): o_maxReportObs contains an invalid value and is set to MAX";
 
   71             call symputx (
"o_maxReportObs", 
"MAX", 
'L');
 
   76    %*************************************************************;
 
   77    %*** testing the assert condition                         ***;
 
   78    %*************************************************************;   
 
   79    %*** Retrieve number of observations in dataset ***;
 
   80    %LET l_nobs=%_nobs(&l_dsname.);
 
   81    %IF (&l_nobs.=0) %THEN %DO;
 
   87    %_getScenarioTestId (i_scnid=&g_scnid, r_casid=l_casid, r_tstid=l_tstid);
 
   89    %*** create subfolder ***;
 
   90    %_createTestSubfolder (i_assertType   =assertRowExpression
 
   97    libname _areLib 
"&l_path.";
 
   99    %*** Count matching observations ***;
 
  101       select count (*) into :l_actual 
 
  105    %IF (&syserr. ne 0) %THEN %DO;
 
  107       %LET l_errmsg=Where expression is not valid!;
 
  108       data _areLib.ViolatingObservations;
 
  112       libname _areLib clear;
 
  116    options obs=&o_maxReportObs.;
 
  117    data _areLib.ViolatingObservations;
 
  118       set &l_dsname (where=(not (&i_where.)));
 
  119       %IF (&o_listVars. ne _NONE_) %THEN %DO;
 
  125    libname _areLib clear;
 
  126    %IF (&l_rc. ne 0) %THEN %DO;
 
  128       %LET l_errmsg=Error writing table with condition violating observations!;
 
  132    %*** Determine results***;
 
  133    %if (&l_actual. eq &l_nobs.) %then %do;
 
  137       %LET l_errmsg =Some observations are violating the condition!;
 
  141    *** update result in test database ***;
 
  142    %_asserts(i_type     = assertRowExpression
 
  143             ,i_expected = &l_nobs.
 
  144             ,i_actual   = &l_actual.
 
  146             ,i_result   = &l_result.
 
  147             ,i_errmsg   = &l_errmsg.
 
  149 %MEND assertRowExpression;