Hi Kurt: Thank you so much for the quick response. the macro variable is inherited from macro program %freqtable(trtgrp=1 2 1+2); %let coln=%sysfunc(countw(%cmpres(&trtgrp),' ')); %do i= 1 %to &coln; %let COLN&i=%sysfunc(compress(%scan(&trtgrp,&i,' '),,kd)); %let _COLN&i=%scan(&column,&i,' '); %end; data all; set xxx; %do i= 1 %to &coln; %if %index(&&_coln&i,+)= 0 %then %let tempcol&i=&&_coln&i; %if %index(&&_coln&i,+)^= 0 %then %let tempcol&i=%sysfunc(tranwrd(&&_coln&i,+,"," )); if _colvars in ("&&tempcol&i") then do; _colvar="&&coln&i."; output; end; %end; run;
... View more