in a data step I would define an array using the : (colon) suffix to include all the colXX variables and just accumulate the last 3 like
Array cols(*) col: ;
last3 = 0 ;
do idx = dim(cols) to dim(cols)-2;
last3+cols( idx);
end;
Then no matter how many COLxx columns are present only the last 3 are summed
The 2025 SAS Hackathon has begun!
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.