It would be useful to know exactly what you are trying to do - saying you need to "access" is unclear. That said, this code does what I think you are asking for, and it will work with any number of weeks.
* Create week totals for each patid;
proc sql;
create table test2 as select distinct patid,week,sum(dose) as WeekTtl
from test group by patid,week order by patid,week;
quit;
* Flip long to wide to get values from every week onto one row;
proc transpose data=test2 out=test2t(drop=_NAME_) prefix=Week;
by patid;
id week;
var WeekTtl;
run;
* Merge transposed data back with original data by patid;
data test3;
merge test test2t;
by patid;
run;
===============
if you do not want to use sql, this duplicates that step.
proc sort data=test out=test4;
by patid week day;
run;
data test4(keep=patid week WeekTtl);
retain WeekTtl;
set test4;
by patid week day;
if first.week then WeekTtl=dose;
else WeekTtl=WeekTtl+dose;
if last.week then output;
run;
ED
... View more