BookmarkSubscribeRSS Feed
bigban777
Obsidian | Level 7

 

DATA covprob;
p = .5;
q = 1-p;
z=abs(probit(.025));
zz=z*z;
do n = 10 to 500;
w = zz / (2 * n);
rad = sqrt(2*w*p*q + w*w);
rt = (p + w + rad)/(1 +2*w);
lt = (p + w - rad)/(1 +2*w);
nhat_rt = floor(n*rt);
nhat_lt = ceil(n*lt - 1);
ncurl_rt = floor((n+4)*rt - 2);
ncurl_lt = ceil((n+4)*lt - 3);
p1 = probbnml(p, n, nhat_lt);
p2 = probbnml(p, n, nhat_rt);
cv_hat = p2 - p1;
p3 = probbnml(p, n, ncurl_lt);
p4 = probbnml(p, n, ncurl_rt);
cv_curl = p4 - p3;
output;
end;
keep n cv_hat cv_curl;
run;

 
 
PROC plot data = covprob;
plot cv_hat*n = '^';
plot cv_curl*n = '~';
run;
quit;
4 REPLIES 4
Reeza
Super User

In what context? Is there a specific part you don't understand?

 

Are you looking for an explanation of a specific line?

Where did you find this code and what are you trying to do with it?

 

PGStats
Opal | Level 21

It looks like some sort of power analysis for (binomial) proportions.  But why reverse engineer this undocumented code? Understand the problem and write your own. And document it!

PG
Reeza
Super User

If it is power analysis it's likely proc power  would likely be a better implementation as well 🙂

bigban777
Obsidian | Level 7
That part:
nhat_rt = floor(n*rt);
nhat_lt = ceil(n*lt - 1);
ncurl_rt = floor((n+4)*rt - 2);
ncurl_lt = ceil((n+4)*lt - 3);


Is it interval? Why it is subtracte -1, -3

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 4 replies
  • 860 views
  • 0 likes
  • 3 in conversation