I tried this below program its working in my SAS Base 9.4 version but not working in SAS Studio. Could you pls help me why is it, Is there anything i'm missing-
##############
%let N=120;
data CIop;
do i=117 to &N;
retain N x p L U alpha;
p=i/&N;
alpha=0.05;
if p=0 then L=0;
if p=1 then U=1;
if p ne 0 then L=(1-betainv(1-alpha/2, &N-i+1, i));
if p ne 1 then U=betainv (1-alpha/2, i+1, &N-i);
N=&N;
x=i;
**diff=L-U;
diff1=L-p;
diff2=round((U-L)/2*100, .01);
output;
end;
run;
proc print data=CIop;
var N x p L U diff2;
run;
###############
Define "not working". Show the SAS log and/or output.
Paste it as text into the window that pops up when you click on the Insert Code button on the forum editor.
1511 %let N=120; 1512 data CIop; 1513 do i=117 to &N; SYMBOLGEN: Macro variable N resolves to 120 1514 1515 retain N x p L U alpha; 1516 p=i/&N; SYMBOLGEN: Macro variable N resolves to 120 1517 alpha=0.05; 1518 if p=0 then L=0; 1519 if p=1 then U=1; 1520 if p ne 0 then L=(1-betainv(1-alpha/2, &N-i+1, i)); SYMBOLGEN: Macro variable N resolves to 120 1521 if p ne 1 then U=betainv (1-alpha/2, i+1, &N-i); SYMBOLGEN: Macro variable N resolves to 120 1522 N=&N; SYMBOLGEN: Macro variable N resolves to 120 1523 x=i; 1524 **diff=L-U; 1525 diff1=L-p; 1526 diff2=round((U-L)/2*100, .01); 1527 output; 1528 end; 1529 run; NOTE: The data set WORK.CIOP has 4 observations and 9 variables. NOTE: DATA statement used (Total process time): real time 0.08 seconds cpu time 0.03 seconds 1530 proc print data=CIop; 1531 var N x p L U diff2; 1532 run; NOTE: There were 4 observations read from the data set WORK.CIOP. NOTE: PROCEDURE PRINT used (Total process time): real time 0.09 seconds
Obs N x p L U diff2 1 120 117 0.97500 0.92868 0.99481 3.31 2 120 118 0.98333 0.94109 0.99798 2.84 3 120 119 0.99167 0.95444 0.99979 2.27 4 120 120 1.00000 0.96973 1.00000 1.51
Define "not working". Show the SAS log and/or output.
Paste it as text into the window that pops up when you click on the Insert Code button on the forum editor.
1511 %let N=120; 1512 data CIop; 1513 do i=117 to &N; SYMBOLGEN: Macro variable N resolves to 120 1514 1515 retain N x p L U alpha; 1516 p=i/&N; SYMBOLGEN: Macro variable N resolves to 120 1517 alpha=0.05; 1518 if p=0 then L=0; 1519 if p=1 then U=1; 1520 if p ne 0 then L=(1-betainv(1-alpha/2, &N-i+1, i)); SYMBOLGEN: Macro variable N resolves to 120 1521 if p ne 1 then U=betainv (1-alpha/2, i+1, &N-i); SYMBOLGEN: Macro variable N resolves to 120 1522 N=&N; SYMBOLGEN: Macro variable N resolves to 120 1523 x=i; 1524 **diff=L-U; 1525 diff1=L-p; 1526 diff2=round((U-L)/2*100, .01); 1527 output; 1528 end; 1529 run; NOTE: The data set WORK.CIOP has 4 observations and 9 variables. NOTE: DATA statement used (Total process time): real time 0.08 seconds cpu time 0.03 seconds 1530 proc print data=CIop; 1531 var N x p L U diff2; 1532 run; NOTE: There were 4 observations read from the data set WORK.CIOP. NOTE: PROCEDURE PRINT used (Total process time): real time 0.09 seconds
Obs N x p L U diff2 1 120 117 0.97500 0.92868 0.99481 3.31 2 120 118 0.98333 0.94109 0.99798 2.84 3 120 119 0.99167 0.95444 0.99979 2.27 4 120 120 1.00000 0.96973 1.00000 1.51
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.