Hi @raja777pharma
Thank you for the clarification.
Here is an attempt to create table3. Let me know if does meet your expectations.
Best,
/* TABLE 3 */
%macro macro2 (prefix = );
data table3_&prefix.;
set table1;
length TYPE $ 5;
TYPE = upcase("&prefix.");
if &prefix.CT = "X" then flag_CT = "CT";
if &prefix.MRI = "X" then flag_MRI = "MRI";
if &prefix.OTH = "X" then flag_OTH = "OTH";
TRT_MULTIPLE = tranwrd(catx("_","TRT",flag_CT,flag_MRI,flag_OTH),"_.","");
if TRT_MULTIPLE = "TRT_CT" then TRT_MULTIPLE = "CT_01";
if TRT_MULTIPLE = "TRT_MRI" then TRT_MULTIPLE = "MRI_02";
if TRT_MULTIPLE = "TRT_OTH" then TRT_MULTIPLE = "OTH_03";
keep SUBNUM VISNAME TESTDAT TYPE TRT_MULTIPLE;
run;
%mend;
%macro2(prefix =TEST);
%macro2(prefix =EXTRA);
%macro2(prefix =MORE);
data table3;
set table3_test table3_extra table3_more;
run;
... View more