BookmarkSubscribeRSS Feed
Kalai2008
Pyrite | Level 9

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 

5 REPLIES 5
PaigeMiller
Diamond | Level 26

@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
Kalai2008
Pyrite | Level 9

Sorry there are 3 Issues. 

Proc report data=test;

column issue fixed id;

define issue/group;

run;

 

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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;
Kalai2008
Pyrite | Level 9

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

Ksharp
Super User

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;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1307 views
  • 1 like
  • 4 in conversation