34 %macro _assertlibrary (i_actual =_NONE_
36 ,i_ExcludeList =_NONE_
37 ,i_CompareCheck=_NONE_
38 ,i_LibraryCheck=_NONE_
47 %LOCAL l_casid l_tstid AnzCompares l_subfoldername l_path;
49 %***
get table names from the two libraries ***;
51 create table WORK._assertLibraryActual as
52 select libname as BaseLibname,
53 memname as BaseMemName,
54 nlobs as BaseObs format=commax18.,
55 nvar as BaseNVar format=commax18.
56 from dictionary.tables
57 where libname =
"%upcase(&i_actual)"
58 %
if (&i_ExcludeList. ne _NONE_) %then %
do;
61 %let l_id_col = %scan (&i_ExcludeList.,&counter., %str ( ));
62 %
do %
while (&l_id_col. ne );
64 %let counter=%eval (&counter.+1);
65 %let l_id_col = %scan (&i_ExcludeList.,&counter., %str ( ));
70 create table WORK._assertLibraryExpected as
71 select libname as CmpLibname,
72 memname as CmpMemName,
73 nlobs as CmpObs format=commax18.,
74 nvar as CmpNVar format=commax18.
75 from dictionary.tables
76 where libname =
"%upcase(&i_expected)"
77 %
if (&i_ExcludeList. ne _NONE_) %then %
do;
80 %let l_id_col = %scan (&i_ExcludeList.,&counter., %str ( ));
81 %
do %
while (&l_id_col. ne );
83 %let counter=%eval (&counter.+1);
84 %let l_id_col = %scan (&i_ExcludeList.,&counter., %str ( ));
91 %*** flag tables according to check results ***;
93 length DoCompare CompareFailed l_rc 8;
94 merge WORK._assertLibraryActual (in=InAct rename=(BaseMemname=memname))
95 WORK._assertLibraryExpected (in=InExp rename=(CmpMemname=memname));
100 if (InAct AND inExp) then
do;
103 if (BaseObs ne CmpObs) then
do;
104 if (
"&i_CompareCheck." =
"STRICT" OR
"&i_CompareCheck." =
"MORECOLUMNS") then
do;
108 if (BaseNVar ne CmpNVar) then
do;
109 if (
"&i_CompareCheck." =
"STRICT" OR
"&i_CompareCheck." =
"MOREOBS") then
do;
114 else if (InAct AND not inExp AND
"&i_LibraryCheck." ne
"STRICT") then
do;
124 %*** determine number of compared tables ***;
126 select sum (DoCompare) into :AnzCompares
130 %if (&AnzCompares. > 0) %then %do;
131 %do i=1 %to &AnzCompares.;
136 select memname into :Memname1-:Memname%trim(&AnzCompares.)
141 %*** upcase for
id columns ***;
142 %if (&i_id. ne _NONE_) %then %do;
143 %let i_id=%upcase (&i_id.);
146 %*** Check for open ODS DESTINATIONS ***;
147 %local OpenODSDestinations;
148 %let OpenODSDestinations=0;
150 %*** SASHELP.VDEST is only available in 9.2 or later ***;
151 %if (&sysver. NE 9.1) %then %do;
153 select count (*) into :OpenODSDestinations from sashelp.vdest;
157 %if (&OpenODSDestinations. = 0) %then %do;
161 %*** Compare each pair of tables ***;
162 %do i=1 %to &AnzCompares.;
163 %if (&i_id. ne _NONE_) %then %do;
167 select distinct upcase (name) into :l_col_names separated by ' '
168 from dictionary.columns
169 where libname = "%upcase (&i_actual.)" AND upcase (memname) = "%upcase(&&memname&i.)";
173 %let l_id_col = %scan (&i_id.,&counter., %str ( ));
174 %do %while (&l_id_col. ne );
175 %let l_found=%sysfunc (indexw (&l_col_names, &l_id_col.));
176 %if (&l_found. > 0) %then %do;
177 %let l_id = &l_id. &l_id_col;
179 %let counter=%eval (&counter.+1);
180 %let l_id_col = %scan (&i_id.,&counter., %str ( ));
185 base=&i_expected..&&memname&i.
186 compare=&i_actual..&&memname&i.
187 %if (&i_fuzz. ne _NONE_) %then %do;
191 %if (&i_id. ne _NONE_) %then %do;
195 %let _sysinfo=&sysinfo.;
197 update work._ergebnis
199 where upcase (memname)="%upcase (&&memname&i.)";
204 %if (&OpenODSDestinations. = 0) %then %do;
208 %*** set test result ***;
215 if ("&i_CompareCheck." = "MOREOBS" OR "&i_CompareCheck." = "MORECOLSNOBS") then do;
220 if ("&i_CompareCheck." = "MORECOLUMNS" OR "&i_CompareCheck." = "MORECOLSNOBS") then do;
225 if ("&i_CompareCheck." = "MORECOLSNOBS") then do;
233 %*** collect results for report ***;
235 length i_LibraryCheck i_CompareCheck $15 i_id i_ExcludeList $80;
237 i_LibraryCheck="&i_LibraryCheck.";
238 i_CompareCheck="&i_CompareCheck.";
240 i_ExcludeList="&i_ExcludeList.";
243 %*** determine return value for test ***;
245 select max (CompareFailed) into :&o_result.
249 %_getScenarioTestId (i_scnid=&g_scnid, r_casid=l_casid, r_tstid=l_tstid);
251 %*** create subfolder ***;
252 %_createTestSubfolder (i_assertType =assertlibrary
259 %*** create library listing ***;
260 *** Capture tables instead of ODS DOCUMENT ***;
261 libname _alLib "&l_path.";
262 ods document name=_alLib._Library_act(WRITE);
263 proc print data=WORK._assertLibraryActual label noobs;
266 ods document name=_alLib._Library_exp(WRITE);
267 proc print data=WORK._assertLibraryExpected label noobs;
270 data _alLib._Library_rep;
273 libname _alLib clear;
275 proc datasets lib=work nolist memtype=(data view);
276 delete _ergebnis _assertLibraryActual _assertLibraryExpected;
278 %mend _assertlibrary;