Please try the below code to derive the sum per year and if you could provide further details on the calculation with example data then we could improvise the code.
data have;
input ID _1995 _1996;
groupx=1;
cards;
1 1 .
2 . 1
3 1 .
;
proc sql;
create table diction as select name from dictionary.columns where libname='WORK' and memname='HAVE' and name not in ('ID' 'GROUPX');
select cat('sum(',strip(name),') as ',strip(name)) into: vars separated by ',' from dictionary.columns where libname='WORK' and memname='HAVE' and upcase(name) not in ('ID' 'GROUPX');
create table want as select &vars from have group by groupx;
quit;
... View more