Boa tarde RxJunior, tive um desafio parecido e criei uma macro que faz quase isso. Você pode alterar para atender sua necessidade. %macro tab_group_concat(tabSAS, tabSaida, coluna); proc sql; select name into :col separated by ' ' from dictionary.columns where libname = "WORK" AND memname= "&tabSAS" and name<>"&coluna"; select name into :colf separated by ', ' from dictionary.columns where libname = "WORK" AND memname= "&tabSAS" and name<> "&coluna" ; select catx(' ', "&coluna") into :colvar from dictionary.columns where libname = "WORK" AND memname= "&tabSAS" and name<> "&coluna"; quit; proc sql; create table ordenado_temp as select * from &tabSAS order by &colf; quit; %put &col; %put &colf; %put &colvar; %let col = &col; %let colf = &colf; %let colvar = &colvar; proc transpose data=ordenado_temp out=temp_mcr name=tipo prefix=col; by &col; var &colvar; run; data temp_mcr1; set work.temp_mcr; if tipo = "&colvar" then do; new_var = CATX(", ", OF col:); end; run; proc sql; CREATE TABLE &tabSaida as select t1.* from (select distinct &colf, new_var as &coluna from temp_mcr1 group by &colf) as t1 where t1.&coluna <> ''; quit; %mend tab_group_concat; data test; Cliente='Jose'; Data_Compra='01/02/2022';output; Cliente='Jose'; Data_Compra='01/03/2022';output; Cliente='Jose'; Data_Compra='01/04/2022';output; Cliente='Jose'; Data_Compra='01/05/2022';output; run; %tab_group_concat(TEST, TESTE, Data_Compra);
... View more