BookmarkSubscribeRSS Feed
sks
Fluorite | Level 6 sks
Fluorite | Level 6
Hello all,
I am trying to build a cross tab report using proc report. In the report I need to get an overall count of records and a count of records with a field ='Y' and then display them next to each other. Let me show you how the data is and what the report should look like


r_type b_type r_amt int_type int_amt
aaa 1111 $10 N 0
aaa 1111 $30 Y $10

aaa 2222 $50 Y $30

bbbb 1111 $15 Y $25

My report needs to look like

r_type b_type b_type_ct b_type_sum int_type_ct int_amt_sum
aaa 1111 2 $40 1 $10
aaa 222 1 $50 1 $30
bbb 1111 1 $15 1 $25

I Have been able to get the b_type_ct and b_type_sum I am using across to get those. But I don't know how to count only the rows with int_type='Y' and then get the sum of int_amt_sum for those rows. I am thinking I need to use some kind of compute block, Please can anyone give me some suggestions on how to do this,

Thanks
Shri
3 REPLIES 3
Cynthia_sas
Diamond | Level 26
Hi:
This looks like a SUMMARY report -- but I do not see INT_TYPE on the report. Unless you put INT_TYPE on the report, it will be very hard to find the count for the INT_TYPE=Y. Is there a reason you don't want to see the count of the Y and the S or the total of the amount for the Y and the S???

PROC REPORT can only count or "work with" items that are placed on the report row. Can you show the code that you've started with??? And any log messages that you've gotten??

cynthia
hellind
Quartz | Level 8

I would like an answer to this question too.

But for now, I change the Y/N character column into 1/0 numeric column. IF  int_type = 'Y' THEN  int_type_flag = 1 ELSE 0;

Then I use this code

proc report data=in;

column r_type b_type int_type_flag;

define r_type b_type/ group;

define int_type_flag / analysis SUM;

run;

Cynthia_sas
Diamond | Level 26

Hi:

  Can you show all the code that you are using so far, including the code that you have used to create int_type_flag???

cynthia

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
  • 3 replies
  • 1469 views
  • 0 likes
  • 3 in conversation