If you absolutely need an array in your solution (and it would make sense to use one for more sophisticated statistics) you could do:
data have;
infile datalines truncover;
input row_num id year salary :dollar10.;
format salary dollar10.;
drop row_num;
datalines;
1 101 2000 $107,000
2 101 2001 $106,000
3 101 2002 $109,000
4 101 2003 $110,000
5 101 2005 $114,000
6 101 2006 $115,000
7 101 2007 $118,000
8 101 2008 $119,000
9 102 2000 $78,000
10 102 2001 $74,000
11 102 2002 $76,000
12 102 2005 $78,000
13 102 2006 $76,000
14 102 2007 $72,000
15 102 2008 $68,000
16 102 2009 $70,000
17 103 2000 $99,000
18 103 2001 $96,000
19 103 2003 $92,000
20 103 2004
;
data want;
array s{99} _temporary_;
call missing(of s{*});
do i = 1 by 1 until(last.id);
set have; by id;
s{i} = salary;
end;
totalSalary = sum(of s{*});
format totalSalary dollar10.;
keep id totalSalary;
run;
proc print noobs; run;
... View more