turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- Base SAS Programming
- /
- Calculate sensitivity and specificity without gene...

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

06-03-2016 03:32 PM

Hi there,

I am trying to calculate sensitivity and specificity of a test (e.g. test2) with reference to a standard test (e.g. test1). I am interested to know a way where I can calculate sensitivity and specificity without multiple proc freq steps. A sample of my data is gievn below:

```
data sensitivity_study;
input test1 test2;
datalines;
1 1
1 0
0 1
0 0
1 1
1 0
0 0
0 0
0 0
0 0
;
run;
```

Thank you in advance for your kind reply.

With Regards,

Deepak

Swain

Accepted Solutions

Solution

06-06-2016
09:42 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

06-03-2016 11:52 PM

All Replies

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

06-03-2016 04:34 PM

This is the same as this question, essentially.

Solution

06-06-2016
09:42 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

06-03-2016 11:52 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

06-06-2016 09:57 AM

Hi Ksharp,

Great solution as I have been looking for without generating 2 by 2 table.

Thanks.

With Kind regards,

Deepak

Swain

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

06-06-2016 09:59 AM

Hi Ksharp,

Is it possible to extend this code to calculate PPV and NPV.

Thank you in advance for your kind reply.

Regards,

Deepak

Swain

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

06-06-2016 09:39 PM

Technically , it could be . Give us formula about them .

Or you could change

sum(test1=test2)/count(*)

into

sum(test1 ne test2)/count(*)

and see whether it is what you want.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

06-08-2016 04:33 PM

Hi Ksharp,

I tried the following sas code but could not generate the desired result.

```
data sensitivity_study;
input test1 test2;
datalines;
1 1
1 0
0 1
0 0
1 1
1 0
0 0
0 0
0 0
0 0
;
run;
proc sql;
select test1,sum(test1 ne test2)/count(*) as ppv,
case when test1=0 then 'NPV' else 'PPV' end as name
from sensitivity_study
group by test1;
quit;
```

Can you kindly help me further.

Positive Predictive Value =True Positive/(True Positive + False Positive) |

Negative Predictive Value=True Negative/(True Negative + False Negative) Thank you in advance for your kind reply. Regards, Deepak |

Swain

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

06-08-2016 05:15 PM

The logic is to write a sum statement with the conditions inside the sum statement that meet your requirements, ie true positive is test1=1 and test2=1.

The first link I posted demonstrates this a bit. You should be able to extend the logic already provided to your new scenario. Please try and post what you've tried and isn't working if you need further help.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

06-08-2016 11:00 PM

OK. Just change GROUP variable into TEST2. data sensitivity_study; input test1 test2; datalines; 1 1 1 0 0 1 0 0 1 1 1 0 0 0 0 0 0 0 0 0 ; run; proc sql; select test2,sum(test1=test2)/count(*) as ppv, case when test2=0 then 'NPV' else 'PPV' end as name from sensitivity_study group by test2; quit;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

06-10-2016 04:20 PM

Hi Ksharp,

Kindly accept my apology for the delayed reply. Your tips has worked nicely and has provided me a very simple way to calulate Sensitivity, Specificity, PPV, NPV without creating 2 by 2 table.

Thanks a lot for your honest effort to help me.

Appreciated.

Regards,

Deepak

Swain