BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I have a report requirement that shows Summary and Detail infomation. The requirement is that the summary level contains many columns fewer than the detail. The user wants the Summary information (with its own header) followed by its detail information below it (with it's own header).
Currently I'm doing this manually in Excel but wanted to try to use proc report.

Below is code from the Revenue table. The first report has, in this example, one less column than the detail report below:

So for example the summary row would appear as:
[summary]
Origin RevBusiness RevEcon
ANC 123480 325791

[detail]
Origin destination RevBusiness RevEcon
ANC RDU 123480 325791



proc report data=SASUSER.REVENUE;
col Origin RevBusiness RevEcon;

define origin/group;
define RevBusiness/ analysis sum;
define RevEcon/ analysis sum;
run;


proc report data=SASUSER.REVENUE;
col Origin dest RevBusiness RevEcon;

define origin/group;
define dest/ group 'destination';
define RevBusiness/ analysis sum;
define RevEcon/ analysis sum;
run;
1 REPLY 1
Cynthia_sas
SAS Super FREQ
Patrick:
Your report program will run much better if you put the option NOWD on the PROC REPORT statement. [pre]
proc report data=sasuser.revenue nowd;
...
[/pre]
The NOWD option prevents the interactive report design window from popping up. If you are submitting your PROC REPORT in batch, this would not happen to you, but in an interactive session of SAS, the REPORT window could pop up and then no other statements would execute until the report window closed.

I'm not sure, from your description, what you want to do. Your code is going to produce 2 tables -- one with 3 report columns (the first proc) and the other table with 4 report columns (the second proc).

When PROC REPORT builds a table, it wants to put the SAME number of columns on every report row. The only exception to this rule is that output from a LINE statement will span ALL the rows. So your first report will ALWAYS have 3 columns on EVERY report row and your second report will ALWAYS have 4 columns on EVERY report row.

It is possible for PROC REPORT to put a summary line BEFORE all the detail lines on a detail report or even a grouped report with some summary lines (such as your second report). This is a powerful feature of PROC REPORT. If you were going to modify the second table to use this feature, then the value for DESTINATION would be blank on this summary row.

To change the second program in this manner, you probably want to add a BREAK BEFORE and maybe a BREAK AFTER statement to your PROC REPORT code:
[pre]
break before origin/summarize skip dol dul ;
break after origin / skip;
[/pre]
OR
[pre]
break before origin/summarize skip dol dul ;
break after origin / page;
[/pre]
However, as I said, this break line would have 4 columns on EVERY row and the column for DESTINATION would just be blank on the summary row.

To see the difference between a detail report with a summary line and a grouped report with a summary line, change the usage of DESTINATION to ORDER for one of your runs and then compare it to the output from when the usage was GROUP for DESTINATION. The difference should stand out.

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
  • 1 reply
  • 576 views
  • 0 likes
  • 2 in conversation