Sorry my bad, to get separate tables for each value of num, when running them all at once, add _&num to the data set name, "want".
data want_#
Adding this, you can utilise the same macro program and append all the output datasets afterwards manually.
data want; set want_1 want_2 want_3 want_4 want_5 want6; run; /*or*/ data want; set want_:; run;
The original code replaces the table "want" every time the macro program is run, that is why you only see the last value (6).
My first suggestion doesn't look to be the most efficient way of doing it if what you require is to have them all in one dataset, even if the desired output can be achieved with the first code. You can simply go over it with a do loop, try this code below instead:
%macro program;
data want;
set have;
%do i=1 %to 6;
%let num=&i;
initial_val=(co&num*(Daily**2)) + (co_dem_&num*Daily) + (int_&num);
exp_val=(co_dem_&num*(co&num*(Daily**2))) + (co_dem_&num*Daily) + (int_&num);
if u_rep=1 and sc=&num then do;
if initial_val > 99.7 then exp_val=1; /*1 if greater than 99.7*/
if initial_val < 99.7 then exp_val=exp_val/100; /*computed value if less than 99.7*/
else exp_val=.; /*null if equal to 99.7*/
end;
%end;
run;
%mend;
%program;
... View more