BookmarkSubscribeRSS Feed
sammmy
Obsidian | Level 7

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.

9 REPLIES 9
PGStats
Opal | Level 21

Please post what code you got so far. Let's start from there.

PG
sammmy
Obsidian | Level 7

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**********************************************************;

 

PGStats
Opal | Level 21

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;
PG
sammmy
Obsidian | Level 7

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

estimated prob plot.PNG

PGStats
Opal | Level 21

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.

PG
sammmy
Obsidian | Level 7

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 

PGStats
Opal | Level 21

If there were no errors, the code should give you a table called graph with the deciles to draw your plot.

PG
Joseph2010
Calcite | Level 5

 

How can this approach be modified to suit cox model? I will be glad also to be assisted.

sammmy
Obsidian | Level 7

I think Same approach can be followed after you have obtained your predicted values from output of PHREG

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