BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
lotteo
Fluorite | Level 6

Hello everybody,

 

I am struggeling with one last step for my data analysis. I have a big Dataset ( over 6000 persons) with and without a desease (variable is called d_an_met_1) and i am analysing the correlation with other variables like BMI, Waist to hip ratio etc (variables called a_anthro_bmi, WHR, S1490 etc). I created the ROC Curves and the layered Roc curve of all variabled with proc logistics but I don't know which curve belongs to which variable. German words are only for labeling so I don't think I need to translate them to you 😄

This is my code:

 

 

ods graphics on;
title Frauen ROC;
proc logistic data=basis_02 order=data PLOTS(MAXPOINTS=NONE);
where basis_sex=2;
class d_an_met_1 ;
model d_an_met_1(event='1')=a_anthro_bmi WHR S4520 S4515 S1510 S6510 S7520 S7545 S8520 S8555 S9510 S9540

/ clparm=wald ;
roc "bmi" a_anthro_bmi;
roc "WHR" WHR;
roc "S4520 - Unterbrustumfang" S4520;
roc "S4515 - Brustumfang" S4515;
roc "S1510 - Halsumfang" S1510 ;
roc "S6510 - Taillenumfang" S6510 ;
roc "S7520 - Gesäßumfang" S7520 ;
roc "S7545 - max. Bauchumfang" S7545 ;
roc "S8520 - Oberarmumfang l." S8520 ;
roc "S8555 - Handgelenkumfang" S8555;
roc "S9510 - Oberschenkelumfang l." S9510 ;
roc "S9540 - Unterschenkelumfang l." S9540 ;

run;
ods graphics off;

 

My Output is a long list of tables and graphs, but the last one is the only one where I need that legend.

Thank you in advance! Have a nice day and week

Greetings Lotte

lotteo_0-1678794122077.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
lotteo
Fluorite | Level 6

Okay the solution was to add a ods graphics /maxlegendarea= statement. Thank you nonetheless. 🙂

View solution in original post

9 REPLIES 9
sbxkoenk
SAS Super FREQ

Hello,

 

On the PROC LOGISTIC statement , add :

PLOTS = ( ROC(UNPACK) )

Does that help?

 

Also, your TITLE statement needs quotes :

title 'Frauen ROC';


Koen

lotteo
Fluorite | Level 6

Hello, 

 

thank you, I tried it and I got this Error-Message:

175 proc logistic data=basis_02 order=data PLOTS(MAXPOINTS=NONE)PLOTS = ( ROC(UNPACK) );
------
73
202
ERROR 73-322: Expecting an ID.
ERROR 202-322: The option or parameter is not recognized and will be ignored.

 

Note: I am new to SAS so new codes are hard to comprehend 😄

 

Thank you

Ksharp
Super User

Did you try ROCCONTRAST statement ?

 

Ksharp_0-1678798071697.png

 

lotteo
Fluorite | Level 6
Yes, but I didn't know how to adjust it to my code. So it didn't work
lotteo
Fluorite | Level 6
Tried it again, but it gave me no legend...
ballardw
Super User

In any case where a procedures graphic options do not provide what you may want you can create a data set of the plot data, modify if needed and then use Proc Sgplot (or sgpanel) to allow more options than are supported by the analysis procedure.

ODS OUTPUT will send plot data to data set, specifics for each proc differ.

Here is an example from the documentation of proc logistic modified to copy the plot data to data sets:

 

data Data1;
   input disease n age;
   datalines;
 0 14 25
 0 20 35
 0 19 45
 7 18 55
 6 12 65
17 17 75
;

ods graphics on;
%let _ROC_XAXISOPTS_LABEL=False Positive Fraction;
%let _ROC_YAXISOPTS_LABEL=True Positive Fraction;

proc logistic data=Data1 plots(only)=roc(id=obs);
   ods output roccurve= curvedata
              fitplot = fitdata
   ; 
   model disease/n=age / scale=none
                         clparm=wald
                         clodds=pl
                         rsquare;
   units age=10;
   effectplot;
run;
%symdel _ROC_XAXISOPTS_LABEL _ROC_YAXISOPTS_LABEL;


Use the ODS TRACE option to see which plot data is made by which procedure.

You will need to examine the output data and may need to reshape it or add variables for specific plots.

I might guess that the sgplot of interest from the above might look like:

proc sgplot data=curvedata;
  series x=_1mspec_    y=_sensit_    /group=_roc_ ;
run;
lotteo
Fluorite | Level 6

Hello, I cant copy the dataset of 6000 Persons into the sas code to create what you suggest, if I understand you correctly. Is there no code to add a legend under my graph? Your code seems complicated, please note that I am a total beginner, your code is not easy for me to understand. Thank you 🙂

ballardw
Super User

@lotteo wrote:

Hello, I cant copy the dataset of 6000 Persons into the sas code to create what you suggest, if I understand you correctly. Is there no code to add a legend under my graph? Your code seems complicated, please note that I am a total beginner, your code is not easy for me to understand. Thank you 🙂


YOU did not provide any data. WE cannot run your code.

The code I provided has a data step to provide code that the Proc logistic can use so you can compare things, possibly adding an ROC statement similar to yours. YOU would not have to do such, though data step is the best way to provide example data so we could test your data. We would not need all the records  or all of the ROC groups, just enough to run with 2.

 

The key part is the ODS OUTPUT which you could add to your code to create a data set.

The SGPLOT code would make a graph, assuming the same variables exist in the curvedata set, with legend for the Group= variable.

The underlying templates for the ROC curve do not have any options to modify legends that I see. The code I provided uses two macro variables that the template uses to allow you to change the labels for the axis but no legend controls.

lotteo
Fluorite | Level 6

Okay the solution was to add a ods graphics /maxlegendarea= statement. Thank you nonetheless. 🙂

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 9 replies
  • 791 views
  • 2 likes
  • 4 in conversation