Your code also looks for a variable named deni and numi, neither of those exist in the data set. You have to use variable names that exist in the data set, otherwise the code will fail.
This seems like a job for an ARRAY.
data ds;
infile datalines dsd truncover;
input id _den1 _den2 _den3 _cnt1 _cnt2 _cnt3;
datalines;
1,4,7,6,0,3,2,
2,4,7,6,1,0,3,
3,4,7,6,0,2,1,
4,4,7,6,2,1,0
;
data want;
set ds;
array n _cnt1-_cnt3;
array d _den1-_den3;
array low _low1-_low3;
array h _high1-_high3;
array r $16 result1-result3;
do i=1 to dim(n);
_pi = round((n(i)/d(i)),.0001);
if _pi=0 then low(i)=0;
if _pi=1 then h(i)=100;
if _pi ne 0 then low(i)=round((1-betainv(.975,(d(i)-n(i)+1),d(i))),.0001)*100;
if _pi ne 1 then h(i)=round((1-betainv(.025,(d(i)-n(i)),n(i)+1)),.0001)*100;
r(i)= '['||strip(put(low(i), 5.1))||', '||strip(put(h(i), 5.1))||']';
end;
run;
This code could be further simplified, but I will leave it as is. Also, wide data sets are usually not preferred, if this was a long data set, no arrays would be needed.
It would help tremendously if you would use the same variable names in your text as in your data set. There is no _numX variable in your data set. I assume you mean _cntX.
... View more