I seriously need help with this. I want to get a calibration plot of Predicted probability on observed event. similar to https://communities.sas.com/t5/SAS-GRAPH-and-ODS-Graphics/Plotting-Calibration-curve-line/td-p/82754
But I just seems not to get it. I really need the codes for the deciles too. And mine seems not to work. I am working on a logistic regression for complex survey, my data is about 60, 000 and only 10% have the event of interest.
Please post what code you got so far. Let's start from there.
In the Proc rank statement, not sure what variable should be in the "var" line
proc import datafile="C:\Users\Downloads\Data variablen.sav"
out=work.usa1
replace;
run;
data live;
set usa1;
WEIGHT=PERWEIGHT/1000000;
run;
**********************Logistic regression model*****************************************************;
PROC surveyLOGISTIC DATA=live ;
strata strata;
cluster PSU;
CLASS KIDSEX (REF="Male")KIDBORD(REF="1")AGE5YEAR(REF=("45-49")MARSTAT (REF="Never married") AGEFIRST(ref="30-49")birth5yrs (ref="More than two")cheb1(ref="> 5")deadkids(ref="Five and above")EDUCLVL(REF="No education")HH5kids(ref="> 5")popage(ref="> 35 years")bednet(ref="No bed net")URBAN (REF="Rural")GEO (REF="NW")/param=glm;
MODEL KIDALIVE (Event = 'No')=KIDSEX KIDBORD AGE5YEAR MARSTAT AGEFIRST birth5yrs cheb1 deadkids EDUCLVL HH5kids popage bednet URBAN GEO /
LINK=LOGIT expb;
output out=pred_ds p=phat;
weight WEIGHT;
RUN;QUIT;
*****************************************end of model*************************************************************;
**********************************************Obtaining deciles*******************************************;
proc rank data=pred_ds groups=10 descending ties=low out=ranked;
var KIDALIVE;
ranks decile;
run;
**********************************************end**********************************************************;
I think you need
proc rank data=pred_ds groups=10 descending ties=low out=ranked;
var phat;
ranks decile;
run;
proc sql;
create table graph as
select
*,
mean(phat) as phatDecile
from ranked
group by decile;
quit;
Dear PG thanks for your time, but the codes you gave is not giving me any output. the plot attach is what I hope to get as my result. I will really appreciate your help. thanks
We can't help you unless you show us some of your code and some of your output. The code I gave you should provide you with the x axis coordinates for your graph.
The codes I gave is what I have so far, I hoped to get codes here that will help me obtain my result since I am not too good with SAS. They codes you gave me ran without error but did not produce any output, so I am still stock
If there were no errors, the code should give you a table called graph with the deciles to draw your plot.
How can this approach be modified to suit cox model? I will be glad also to be assisted.
I think Same approach can be followed after you have obtained your predicted values from output of PHREG
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.