45%macro mp_searchdata(lib=
52 ,filter_text=%str(1=1)
55%local table_list table table_num table colnum col start_tm check_tm vars type
57%put process began at %sysfunc(datetime(),datetime19.);
59%
if &syscc ge 4 %then %
do;
60 %put %str(WAR)NING: SYSCC=&syscc on macro entry;
64%
if &
string = %then %let type=N;
67%
if "&outloc"=
"0" %then %
do;
68 %let outloc=%sysfunc(pathname(work))/%mf_getuniquename();
72libname &outlib
"&outloc";
76select distinct memname into: table_list separated by
' '
77 from dictionary.tables
78 where upcase(libname)=
"%upcase(&lib)"
80 and upcase(memname)=%upcase(
"&ds")
84%
if %length(&table_list)=0 %then %put library &lib contains no tables!;
86%
else %
do table_num=1 %to %sysfunc(countw(&table_list,%str( )));
87 %let table=%scan(&table_list,&table_num,%str( ));
88 %let vars=%mf_getvarlist(&lib..&table);
89 %
if %length(&vars)=0 %then %
do;
90 %put NO COLUMNS IN &lib..&table! This will be skipped.;
93 %let check_tm=%sysfunc(datetime());
97 where %unquote(&filter_text) and ( 0
99 %
do colnum=1 %to %sysfunc(countw(&vars,%str( )));
100 %let col=%scan(&vars,&colnum,%str( ));
101 %let coltype=%mf_getvartype(&lib..&table,&col);
102 %
if &type=C and &coltype=C %then %
do;
104 or (
"&col"n ?
"&string")
106 %
else %
if &type=N and &coltype=N %then %
do;
108 or (
"&col"n = &numval)
112 %
if &outobs>-1 %then %
do;
113 if _n_ > &outobs then stop;
116 %put Search query
for &table took
117 %sysevalf(%sysfunc(datetime())-&check_tm) seconds;
118 %
if &syscc ne 0 %then %
do;
119 %put %str(ERR)ROR: SYSCC=&syscc when processing &lib..&table;
122 %
if %mf_nobs(&outlib..&table)=0 %then %
do;
124 drop table &outlib..&table;
129%put process finished at %sysfunc(datetime(),datetime19.);