2 users online | 2 Guests and 0 Registered

Can I keep all of the repeating GROUP / ORDER values in PROC REPORT?


PROC REPORT is a hugely versatile reporting procedure and comes with a number of inbuilt features - for example when a column is defined as either GROUP or ORDER the procedure automatically suppresses the repetitious printing of the values.

While this is helpful in a report to assist with easily identifying groups of data, it can cause problems if the data is written to an external destination (e.g. Excel) where the repetition is necessary.

For example the following code generates a report and suppresses the values of the sex column:

proc report data = sashelp.class nowd ;
column sex name age ;
define sex / order ;

This produces a report as shown:

 PROC REPORT - suppressed values

To keep all sex values, it is necesssary to use a COMPUTE-ENDCOMP block and a dummy variable.  Each time the sex column displays a value it is stored in the dummy variable, and whenever the column is blank, the dummy variable is used to re-populate the column.

The code now appears as follows:

proc report data = sashelp.class nowd ;
column sex name age ;
define sex / order ;
compute sex / character ;
if sex ne '' then dummy = sex ;
else sex = dummy ;
endcomp ;
run ;

which generates the desired report:

PROC REPORT - no suppressed values

Author:
Alan D Rudland
Revision:
1.1
Average rating: 1 (1 Vote)

You cannot comment on this entry

Chuck Norris has counted to infinity. Twice.