Hi,
I have code to find mean of cv_hat (coverage value) and cv_curl:
Data propns;
seed = 123475;
nr = 10000; nc = 12;
array x[20];
zstar = abs ( probit(0.025) );
ppop = 0.5;
do r = 1 to nr;
do c = 1 to nc;
x[c] = ranbin(seed, 1, ppop);
nh = sum(of x[*]);
phat = nh / nc;
se_phat = sqrt( phat * (1-phat) / nc);
pcurl = (nh + 2)/(nc + 4);
se_pcurl = sqrt( pcurl * (1-pcurl) / (nc+4) );
zhat = (phat - ppop)/se_phat;
zcurl = (pcurl - ppop)/se_pcurl;
if abs(zhat) <= zstar then cv_hat = 1;
else cv_hat = 0;
if abs(zcurl) <= zstar then cv_curl = 1;
else cv_curl = 0;
end;
output;
end;
keep phat se_phat pcurl se_pcurl zhat zcurl cv_hat cv_curl;
run;
PROC means data = propns n mean stderr;
var cv_hat cv_curl;
run;
That is code for nc=12. I need for : from 10 to 100. Therefore, i need 91 means for cv_hat and cv_hat. Moreover, i need a graph
means|
|
|
|
|_______________
nc
Thank you
P.S. Please show me how change my code (how use loop)
|
|
Look at the legend option and statement, and at the axis statement.
Like this?
data PROPNS;
array X[100];
SEED = 123475;
NR = 10000;
PPOP = 0.5;
ZSTAR = abs ( probit(0.025) );
do NC = 10 to 100;
call missing (of X[*]);
do R = 1 to NR;
do C = 1 to NC;
X[C] = ranbin(SEED, 1, PPOP);
NH = sum(of X[*]);
PHAT = NH / NC;
SE_PHAT = sqrt( PHAT * (1-PHAT) / NC);
PCURL = (NH + 2)/(NC + 4);
SE_PCURL= sqrt( PCURL * (1-PCURL) / (NC+4) );
ZHAT = divide(PHAT - PPOP, SE_PHAT );
ZCURL = divide(PCURL - PPOP, SE_PCURL);
CV_HAT = (abs(ZHAT) <= ZSTAR );
CV_CURL = (abs(ZCURL) <= ZSTAR);
end;
output;
end;
end;
keep NC PHAT SE_PHAT PCURL SE_PCURL ZHAT ZCURL CV_HAT CV_CURL;
run;
proc means data = PROPNS n mean stderr nway;
class NC;
var CV_HAT CV_CURL;
output out=SUM mean= ;
run;
proc gplot data=SUM;
plot (CV_HAT CV_CURL)*NC/overlay;
run;
quit;
I got this. Thank you so much. Could you show me how label each line( red and blue) and it shows just CV_HAT, i believ should be CV_HAT, CV_CURL.
Thank you
Look at the legend option and statement, and at the axis statement.
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.