BookmarkSubscribeRSS Feed
MKar
Calcite | Level 5

Hi,

I am doing a diagnostic test accuracy study for a screening test versus the gold standard. I have searched codes for performing sensitivity and specificity and PPV and NPV. I have used this macro to get sen and spec and PPV and NPV.

 

/*for sensitivity*/

 

ods rtf; ods listing close;
%macro se (q);
proc freq data=DATA order= formatted;
where &q =1;
tables gold / binomial(level='yes');
exact binomial;
title "Specificity/ exposure as test/variables as response" &q; run;
%mend sp;

%se (variable1);
%se (variable2);
run; ods rtf close; ods listing; quit; run;

 

1- I do not know what (q) means.

2- Do I need "order=formatted"?

3- Why for variable1 sas calculated all records in my data but for variable2 sas used only part of data. It means that table of frequency "yes no" and cumulative frequency are not the same. For variable1 cumulative is correct (total of yes no) but for variable2 cumulative is only for (yes). I think the analysis is not right for variable2.

 

Thank you for you help.

 

 

1 REPLY 1
ballardw
Super User

Q would the name of the variable you are using to restrict records to those with a value of 1. I would have to assume the 1 means something specific in terms of your process.

 

You do not need to use order=formatted. That might change the order of display of the variable Gold in the result tables. The default order is internal, which would be the sort order of the underlying values of a variable.

 


@MKar wrote:

Hi,

I am doing a diagnostic test accuracy study for a screening test versus the gold standard. I have searched codes for performing sensitivity and specificity and PPV and NPV. I have used this macro to get sen and spec and PPV and NPV.

 

/*for sensitivity*/

 

ods rtf; ods listing close;
%macro se (q);
proc freq data=DATA order= formatted;
where &q =1;
tables gold / binomial(level='yes');
exact binomial;
title "Specificity/ exposure as test/variables as response" &q; run;
%mend sp;

%se (variable1);
%se (variable2);
run; ods rtf close; ods listing; quit; run;

 

3- Why for variable1 sas calculated all records in my data but for variable2 sas used only part of data. It means that table of frequency "yes no" and cumulative frequency are not the same. For variable1 cumulative is correct (total of yes no) but for variable2 cumulative is only for (yes). I think the analysis is not right for variable2.

 

Thank you for you help.


The variable you are passing to the macro SE is used to select records. It will only process those where the value of the variable=1.

So "correctness" depends on the content of your data and the actual intended analysis. It may be that your variable2 has values of 1 only when (gold?) has values of yes. Interpretation depends on what you have set up.

Catch up on SAS Innovate 2026

Nearly 200 sessions are now available on demand in the Innovate Hub.

Watch Now →

Health and Life Sciences Learning

 

Need courses to help you with SAS Life Sciences Analytics Framework, SAS Health Cohort Builder, or other topics? Check out the Health and Life Sciences learning path for all of the offerings.

LEARN MORE

Discussion stats
  • 1 reply
  • 2175 views
  • 0 likes
  • 2 in conversation