Thanks again for the response. I tried to frame a sample test data as below. There can be a case where date fields can be also used for grouping, as these are dynamic variables. Input - Dataset b; Input id name$ sale1 sale2 sale3 date1; Cards; 1 aa 10 20 30 1 aa 5 7 10 2 bb 28 60 6 2 cc 10 5 5 2 cc 6 6 6 ; Run; Field to which aggregate function needs to be mapped comes from another table as below.From this table the macro variables &aggfunc and &grouplist are created. Field Func ID group Name group Sale1 min Sale2 min Sale3 sum %put &aggfunc; ID,Name,Min(sale1) as sale1, min(sale2) as sale2, min(sale3) as sale3 %put &grouplist; ID,Name Proc sql; Create table as sum_out as Select &aggfunc., &grouplist. From B Group by &grouplist; Quit; Output dataset result - sum_out 1 aa 5 7 40 2 bb 28 60 6 2 cc 6 5 11
... View more