The code you have shown seems to create the data you show as needed.
What is the problem?
If it is that you have more than one week's spending in some observations, you just need to output each row:
DATA Assignment2_new_data_merged3;
set Assignment2_new_data_merged2;
array WK WK080116 -- WK042720;
do over WK;
if Release_week = substr(vname(WK),3,6) then do;
Spending_in_week_0 = WK;
output;
end;
end;
run;
... View more