DATA Step, Macro, Functions and more

Summary Report

Reply
Frequent Contributor
Posts: 94

Summary Report

[ Edited ]

I have a dataset like this

ID      Issue     Fixed
1       Issue 1    yes
2       Issue 2   no
3       Issue 3   yes
4       Issue 1   yes
4       Issue 3   no
5       Issue 1   no
5      Issue 2   yes
5      Issue 3   no

........
There are 3 Issues (Issue1-Issue3), Each id can fall into multiple issues.

I want to get a summary report like this.  I tried Proc report, but I am not getting my desired output.

Issue     Yes    no    Total
Issue 1    2     1      3
Issue 2    1     1      2
Issue 3    1      2     3

 

Thanks 

Respected Advisor
Posts: 2,802

Re: Summary Report

Posted in reply to Kalai2008

Kalai2008 wrote:

I have a dataset like this

ID      Issue     Fixed
1       Issue 1    yes
2       Issue 2   no
3       Issue 3   yes
4       Issue 1   yes
4       Issue 3   no
5       Issue 1   no
5      Issue 2   yes
5      Issue 3   no

........
There are 5 Issues (Issue1-Issue5), Each id can fall into multiple issues.

I want to get a summary report like this.  I tried Proc report, but I am not getting my desired output.

Issue     Yes    no    Total
Issue 1    2     1      3
Issue 2    1     1      2
Issue 3    1      2     3

 

Thanks 


I see only 3 issues, not 5.

 

Show us your PROC REPORT code, and we should be able to help you fix it.

--
Paige Miller
Frequent Contributor
Posts: 94

Re: Summary Report

Posted in reply to PaigeMiller

Sorry there are 3 Issues. 

Proc report data=test;

column issue fixed id;

define issue/group;

run;

 

Super User
Super User
Posts: 9,397

Re: Summary Report

Posted in reply to Kalai2008

Not tested as no test data, but:

proc sql;
  create table WANT as
  select  ISSUE,
          sum(case when FIXED="yes" then 1 else 0 end) as YES,
          sum(case when FIXED="no" then 1 else 0 end) as NO,
          count(*) as TOTAL
  from    HAVE
  group by ISSUE;
quit;
Frequent Contributor
Posts: 94

Re: Summary Report

Thank you so much. It worked in Proc SQL.  Is there any way I can do this in Proc Report or Proc Summary?..

Super User
Posts: 10,681

Re: Summary Report

Posted in reply to Kalai2008

It is best for proc tabulate.

 

data have;
input id Issue  & $20.   Fixed $;
cards;
1       Issue 1    yes
2       Issue 2   no
3       Issue 3   yes
4       Issue 1   yes
4       Issue 3   no
5       Issue 1   no
5      Issue 2   yes
5      Issue 3   no
;
run;

proc tabulate data=have;
class issue fixed;
table issue,fixed*n all;
keylabel n=' ';
run;
Ask a Question
Discussion stats
  • 5 replies
  • 110 views
  • 1 like
  • 4 in conversation