have a try. data raw; input Code Date $ Amount @@ ; datelines; 0 31.01.2020 100 1 29.02.2020 80 2 31.03.2020 120 1 30.04.2020 75 2 31.01.2020 200 2 29.02.2020 150 4 31.03.2020 125 0 30.04.2020 230 1 31.01.2020 75 1 29.02.2020 65 3 31.03.2020 80 4 30.04.2020 90 0 31.01.2020 500 0 29.02.2020 350 1 31.03.2020 200 1 30.04.2020 100 p; run; proc sql; create table final select distinct date, total ,sum ( code_0) as code0 ,sum ( code_1) as code1 ,sum ( code_2) as code2 ,sum ( code_3) as code3 ,sum ( code_4) as code4 from (select date, sum(amount),case when code =0 then amount as code_0, case when code =1 then amount as code_1, case when code =2 then amount as code_2, case when code=3 then amount as code_3, case when code=4 then amount as code_4 from raw group by date) group by date; quit;
... View more