I created two macro variables in my sas code using the %let option.
data sasdata1.dataone;
set sasdata1.dataone ;
%let week=1;
%let sum=0;
do i=1 to 53;
%let sum= _W&week._NRX + &sum.;
week=&week+1;
end;
drop i;
week=&week;
sum=&sum.;
run;
the value of the week variable remains 1 even after the loop has executed. Which is the correct way to change the value of Macro variables?
%do &week=1 %to 53; <do something>; %end;. Another issue (with the example code you've posted) is that you're usingias your iterator variable, but trying to increment a variable calledweek. - sasfrog_W1_NRXto_w53_NRX? And do you just want to create a variable calledsumthat adds them up for eachrowof data? - sasfrog