Dear SAS Gurus, please help me debugging my loop. %let k_interims = 5;
%let n_1 = 100;
%let n_2 = 100;
%let n_3 = 100;
%let n_4 = 100;
%let n_5 = 100;
%let i_nullprop_mean = 0.5;
%let i_nullprop_SD = 0.1;
%let j_alternative_mean = 0.5;
%let j_alternative_SD = 0.1;
data _null_;
do i=1 to &k_interims by 1;
s= '
data count_'||trim(left(put(i,3.)))||' (drop=j);
length trt sbi 4;
if '||trim(left(put(i,3.)))||' eq "1" or '||trim(left(put(i,3.)))||' eq 1 then do;
do j = 1 to round(&n_'||trim(left(put(i,3.)))||', 2) by 1;
if mod(j, 2) eq 0 then do;
trt = 1;
sbi = rand("Bernoulli", abs(rand("Normal", &j_alternative_mean, &j_alternative_SD)));
end;
else do;
trt = 0;
sbi = rand("Bernoulli", abs(rand("Normal", &i_nullprop_mean, &i_nullprop_SD)));
end;
output;
end;
end;
else if '||trim(left(put(i,3.)))||' ne "1" or '||trim(left(put(i,3.)))||' ne 1 then do;
set count_'||trim(left(put(i-1, 3.)))||';
do j = 1 to round(&n_'||trim(left(put(i,3.)))||', 2) by 1;
if mod(j, 2) eq 0 then do;
trt = 1;
sbi = rand("Bernoulli", abs(rand("Normal", &j_alternative_mean, &j_alternative_SD)));
end;
else do;
trt = 0;
sbi = rand("Bernoulli", abs(rand("Normal", &i_nullprop_mean, &i_nullprop_SD)));
end;
output;
end;
end;
run;
';
call execute(s);
end;
run; results in right at the first if statement for the case that i=1: ERROR: File WORK.COUNT_0.DATA does not exist. I don't understand why SAS does not accept the case: if '||trim(left(put(i,3.)))||' eq "1" or '||trim(left(put(i,3.)))||' eq 1 then do; As you can see I tried to resolve by handling i as a character. In python I would simply put a: print(i) in between the loop. How is it possible to debug such cases? THX and BR Lukas
... View more