For an ADAM data set it is necessary to use data in SDTM domain along with its respective SUPPQUAL domain. The programmer needs to follow necessary steps to transpose, rename and transform the IDVARs mentioned in the SUPPQUAL. This is a repetitive task and based on the power bestowed by CDISC through the SDTM metadata this process can be converted to a generic and reusable macro. I have tried to do the same here. This macro merges the SUPPQUAL domain with the SDTM domain for each different idvars and idvarvals combinations present in the SUPPQUAL
/Macro to merge SDTM data set with respective SUPP dataset for all distinct IDVAR in SUPP dataset INPUTS = DS1 is the SDTM dataset DS2 is the SUPP dataset ASSUMPTIONS: Both datasets should be in work library Look For a dataset with fin suffix as the final output WARNING Not to be run where IDVAR is blank example DM SDTM dataset/This enhancement can be added within the macro
%macro mergesupp(ds1=,ds2=);
/Creates a macro variable with distinct IDVARs from the SUPP dataset in the macro variable/
proc sql ;
select distinct idvar into :idvar separated by ” “
from &ds2;
quit;
/iterations for the number of words in the macro i.e. number of distinct IDVARs in the SUPP dataset/
%do i=1 %to %sysfunc(countw(&idvar));
%let seq=%scan(&idvar,&i);
proc sort data=&ds2 out=&ds2.2 ;
by usubjid idvar idvarval;
where idvar =”&seq”;
run;
data &ds2.2&i(rename =(idvarval2=&seq));
set &ds2.2;
idvarval2= input(idvarval,best.);
drop idvarval ;
run;
proc sort data=&ds2.2&i;
by usubjid &seq;
run;
/* Transposing for each IDVAR and creates a separate dataset for each distinct idvar*/
proc transpose data=&ds2.2&i out=&ds2.tr&i(drop =name label) ;
by usubjid &seq;
var qval;
id qnam;
idlabel qlabel;
run;
proc sort data=&ds1;
by usubjid &seq;
run;
proc sort data=&ds1 out=&ds1.&i;
by usubjid &seq;
run;
proc sort data=&ds2.tr&i;
by usubjid &seq;
run;
%end;
/* for first iteration the a dataset is created that is a product of merging of first
IDVAR transposed dataset and SDTM dataset*/
%do i=1 %to %sysfunc(countw(&idvar));
%let seq=%scan(&idvar,&i);
%if &i=1 %then %do;
data &ds1.1;
merge &ds1 &ds2.tr&i;
by usubjid &seq;
run;
%end;
/* for the second and greater iterations datasets are created for each iterations based on
number of distinct idvars greater than 1*/
%else %if &i ne 1 %then %do;
data &ds1.&i;
merge &ds1.%eval(&i-1) &ds2.tr&i;
by usubjid &seq;
run;
%end;
%end;
%let boom=%sysfunc(countw(&idvar));
/* final data set is with suffix fin*/
%if &boom = 1 %then %do;
data &ds1.2fin;
set &ds1.1;
run;
%end;
%else %if &boom ne 1 %then %do;
data &ds1.&boom.fin;
set &ds1.&boom;
run;
%end;
run;
%mend;
%mergesupp(ds1=lb,ds2=supplb);






















