BookmarkSubscribeRSS Feed
EricCai
Calcite | Level 5

Dear Community,

At the suggestion of Cynthia@sas, I am re-posting this question in this group.  (I originally posted it in SAS Macro Facility, Data Step and SAS Language Elements.)

I have a macro that successfully creates 2x2 contingency tables, one for each value of a variable X.  The contingency tables are created from PROC FREQ.

Now, I would like to

1) calculate the specificity and sensitivity from each table

2) plot all pairs of sensitivity and 1-specificity to create an ROC curve (sensitivity vs. 1-specificity) for all values of X

Is there a way to automate this in SAS?  I can't find a way to do so via searching on Google or SAS documentation.

I envision the successful macro being able to

a) extract the counts from each cell in each contingency table

b) calculate sensitivity and 1-specificity for each contingency table

c) plot sensitivity vs. 1-specificity

but I can't figure out how to do this.  (I'm sure that DO-loops and arrays are needed somehow.)

Thus, right now, I am typing the counts by hand into Microsoft Excel and plotting the ROC curve there.  This worked initially when I only had to create 5 ROC curves, but I now need to produce 20, and I wish to automate this process.                           

Any help that you can provide would be much appreciated!

Thanks,

Eric

2 REPLIES 2
sunnyrj
Calcite | Level 5

Eric,

Go to Lex Jansen's wonderful website - www.lexjansen.com  and search for the SUGI paper "Constructing ROC Curves with the SAS System" by Andrew Stead.  The paper contains a nice macro for calculating and plotting ROC curves.

Renee

EricCai
Calcite | Level 5

Hi Renee,

Thanks for the suggestion, and sorry for the late reply.  After much trying in SAS, I realized that it would be easier to plot the ROC curves in R, so I proceeded to do that successfully and smoothly.  There were many curves that I needed to draw, and I needed to do a lot of annotation and colour-coding, so I'm glad that I did it in R.

Thanks again,

Eric

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 2 replies
  • 1360 views
  • 0 likes
  • 2 in conversation