I can tell you half a dozen ways to do this, but don't know a macro function to just give you what you want. The simplest one I know of would be:
data temp;
input name $ days_away;
cards;
fred 12
fred 15
fred 17
fred 23
joe 5
joe 7
joe 12
run;
proc sql;
create table seven as select name, sum(days_away) as sumday from temp group by name;
quit;
PROC TRANSPOSE DATA=TEMP OUT=SIX (DROP=_NAME_) PREFIX=DAYS_AWAY;
BY NAME;
VAR DAYS_AWAY;
RUN;
data six;
merge six seven;
by name;
run;
Otherwise you are going to have to run a datastep or sql to find the maximum number of values by name or find the maximum suffix for the variable name from the sashelp views or dictionary tables. You can parse the variable name from them to get that value.
... View more