BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Akter
Obsidian | Level 7

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;

###############

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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

View solution in original post

1 REPLY 1
Tom
Super User Tom
Super User

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

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 326 views
  • 0 likes
  • 2 in conversation