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;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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