options nodate nocenter; %macro diag_plot(data, dep, predictors, num); proc logistic data = &data descending; model &dep = &predictors ; output out=_temp_ p=pi; run; data _temp_; set _temp_; pihat = log( pi / (1 - pi) ); run; proc sort data = _temp_; by pihat; run; data _temp_; set _temp_ nobs=total; class = .; class = int( ( _n_ - 1 )/( total/&num ) ) + 1; run; proc sql; create table _temp1_ as select *, min(pihat) + ( max(pihat) - min(pihat) )/2 as midpoint, max(pihat) as max, min(pihat) as min, sum(y)/count(y) as pj, count(y) as n from _temp_ group by class; quit; proc sort data = _temp1_ (keep = class n min max midpoint pj); by class ; run; data _temp1_; set _temp1_; by class; if first.class; run; proc print data=_temp1_; var class min max midpoint n pj; run; goption reset = all; symbol1 v=dot i=spline c=blue; axis1 order=( 0 to 1.0 by 0.1); proc gplot data=_temp1_; plot pj*midpoint / vaxis = axis1; run; quit; %mend;