/**********************************************************************/


data disease;
   input y exposure freq;
   cards;
0 0 45
0 1 5
1 0 10
1 1 40
;

proc logistic data=disease;
   model y=exposure;
   freq freq;
run;


/**********************************************************************/


proc logistic data=disease descending;
   model y=exposure; 
   freq freq; 
run;


/**********************************************************************/


proc format;
   value disfmt 1=ĠdiseaseĠ 0=Ġno diseaseĠ;
run;

proc logistic data=disease; 
   model y=exposure;
   freq freq;
   format y disfmt.; 
run;


/**********************************************************************/


proc sort data=disease; 
   by descending y;
run;

proc logistic data=disease order=data; 
   model y=exposure;
   freq freq; 
run; 


/**********************************************************************/


data disease2;
   set disease;
   if y=0 then y1=Ġno diseaseĠ;
   else y1=ĠdiseaseĠ;
run;

proc logistic data=disease2; 
   model y1=exposure;
   freq freq; 
run; 


/**********************************************************************/


data disease3; 
   set disease; 
   n=1;
run;

proc logistic data=disease3; 
   model y/n=exposure; 
   freq freq; 
run;


/**********************************************************************/


proc logistic data=age descending;
   model y=age;
run;


/**********************************************************************/


proc logistic data=disease descending;
   model y=exposure;
   freq freq;
   output out=probs predicted=phat;
run;


/**********************************************************************/


proc logistic data=age descending;
    model y=age;
    output out=probs predicted=phat;
run;

data probs;
    set probs;
    pred_dis=0;
    if phat>=0.5 then pred_dis=1;
run;


/**********************************************************************/


proc freq data=probs;
   tables y*pred_dis / norow nocol nopercent;
run;

 
/**********************************************************************/


proc logistic data=age descending;
   model y=age / ctable pprob=(0.05 to 0.5 by 0.05);
run;


/**********************************************************************/


data unknown;
   set age2;
   yactual=y;
   y=.;
run;


/**********************************************************************/


data both;
   set unknown age;
run;


/**********************************************************************/


proc logistic data=both descending;
   model y=age;
   output out=probs predicted=phat;
run;


/**********************************************************************/


data probs;
   set probs;
   pred_dis=0;
   if phat>=0.25 then pred_dis=1;
run;


/**********************************************************************/


proc freq data=probs;
   tables yactual*pred_dis / norow nocol nopercent;
run;


/**********************************************************************/