@ssv:
Generate a list of all data set names where a supp domain name matches a parent domain name, then go through the names in the list in a loop. Sort of like:
proc sql noprint ;
select memname into :supplist separated by " " from dictionary.tables where libname = "WORK" and memname not eqt "SUPP"
and memname in (select substr (memname, 5) from dictionary.tables where libname = "WORK" and memname eqt "SUPP")
;
quit ;
%macro combine (list=, dst=) ;
%local i ;
%do i = 1 %to sysfunc (countw (&list)) ;
%let in = %scan (&list, &i) ;
proc sort data = &in out = &in ;
by usubjid &in.seq ;
run ;
proc sort data = supp&in out = supp&in ;
by usubjid idvarval qnam ;
run ;
proc transpose data = supp&in out = supp&in._ (drop = _:) ;
by usubjid idvarval ;
id qnam ;
idlabel qlabel ;
var qval ;
run ;
data supp&in._ (drop = idvarval) ;
set supp&in._ ;
&in.seq = input (idvarval, best.) ;
run ;
proc sort data = supp&in._ ;
by usubjid &in.seq ;
run ;
data &in._merg ;
merge &in (in = _in) supp&in._ ;
by usubjid &in.seq ;
if _in ;
run ;
%end ;
%mend ;
%combine (list=&supplist)
This way, you don't have to call the same macro a bunch of times and/or determine which domains to use as an argument by eyeballing your library. Leave this tedious and error-prone work to the computer - you're using it anyway.
Kind regards
Paul D.
... View more