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
SAS Super FREQ
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
SAS Super FREQ

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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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