DATA Step, Macro, Functions and more

Creating a 2x2 table in Proc Report

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 76
Accepted Solution

Creating a 2x2 table in Proc Report

[ Edited ]

Hello,

 

I would like to report the following count data:

TP FN FP TN
12 110 14 99

 

in a proc report as the following:

 

    Gold Standard
    + -
Result + 12 14
- 110 99

 

 

I am having some difficulty as to how I can manipulate the cells/ add rows. I would think this was a common problem, but I am having difficulty googling it. Below is the SAS code for the dataset:

 

 

data ex1;
input TP    FN    FP     TN;
cards;
12 110 14 99
;
run;

 

Any suggestions or links to the right direction would be much appreciated,

 


Accepted Solutions
Solution
‎06-26-2017 04:17 PM
Trusted Advisor
Posts: 1,934

Re: Creating a 2x2 table in Proc Report

[ Edited ]
Posted in reply to daszlosek

If you read in your data differently so that each row has only one data point, and a + or - value for Gold Standard, and another + or - value for Result, then you're all set. See http://documentation.sas.com/?cdcId=pgmmvacdc&cdcVersion=9.4&docsetId=proc&docsetTarget=n1pl56sdqo09...

 

data have;
    input gold_standard $ result $ value;
+ + 12
+ - 110
- + 14
- - 99
;
run;

  

View solution in original post


All Replies
Solution
‎06-26-2017 04:17 PM
Trusted Advisor
Posts: 1,934

Re: Creating a 2x2 table in Proc Report

[ Edited ]
Posted in reply to daszlosek

If you read in your data differently so that each row has only one data point, and a + or - value for Gold Standard, and another + or - value for Result, then you're all set. See http://documentation.sas.com/?cdcId=pgmmvacdc&cdcVersion=9.4&docsetId=proc&docsetTarget=n1pl56sdqo09...

 

data have;
    input gold_standard $ result $ value;
+ + 12
+ - 110
- + 14
- - 99
;
run;

  

Frequent Contributor
Posts: 76

Re: Creating a 2x2 table in Proc Report

Posted in reply to PaigeMiller
I can see that I could just transpose the data to get it into that format, but I am not seeing how, in proc report, I could get the 12 adjacent to the 14. In the past using proc report I have just added columns, not rows.
Trusted Advisor
Posts: 1,934

Re: Creating a 2x2 table in Proc Report

Posted in reply to daszlosek

I gave the link to an example that does this.

Frequent Contributor
Posts: 76

Re: Creating a 2x2 table in Proc Report

Posted in reply to PaigeMiller
Yes, my apologies didn't see the link. With a little tweaking I was able to format the data the way I wanted.
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 148 views
  • 0 likes
  • 2 in conversation