BookmarkSubscribeRSS Feed
SanjayM
Calcite | Level 5
The following code shows the output summarised on Product and Grand total for Region

proc report data=sashelp.shoes;
COLUMN Region Product Subsidiary Sales;
DEFINE Region / group width=20;
DEFINE product / group width=20;
DEFINE Sales / ANALYSIS SUM;
*break after Product / summarize;

COMPUTE AFTER Product ;
LINE @59 'TOTAL'
@89 Sales.Sum ;
LINE '';
ENDCOMP;
COMPUTE AFTER ;
LINE @59 'GRAND TOTAL'
@89 Sales.Sum;
LINE '';
ENDCOMP;

run;

How can I get the Region and Product values repeating and not supressed.
1 REPLY 1
Cynthia_sas
Diamond | Level 26
Hi:
Basically, suppression of repeating values is what comes with ORDER and GROUP usage. You can't make them work any differently. However, you can create a new report item that is assigned the value for region and group. But, to do that you have to "grab" those values in a COMPUTE BEFORE ... block and then save them in a temporary variable. Then you use the temporary variable to assign a value to the column that shows up on the report.

cynthia
[pre]
proc report data=sashelp.shoes nowd;
COLUMN Region newreg Product newprod Subsidiary Sales;
DEFINE Region / group width=20 noprint;
define newreg /computed 'Region';

DEFINE product / group width=20 noprint;
define newprod /computed 'Product';

DEFINE Sales / ANALYSIS SUM;
*break after Product / summarize;

compute before Region;
** "grab" the region value before it is suppressed;
holdreg = Region;
endcomp;
compute newreg / character length=20;
newreg = holdreg;
endcomp;

compute before Product;
** "grab" the product value before it is suppressed;
holdprod = Product;
endcomp;
compute newprod/ character length=20;
newprod = holdprod;
endcomp;

COMPUTE AFTER Product ;
LINE @59 'TOTAL'
@89 Sales.Sum ;
LINE '';
ENDCOMP;
COMPUTE AFTER ;
LINE @59 'GRAND TOTAL'
@89 Sales.Sum;
LINE '';
ENDCOMP;

run;
[/pre]

Catch up on SAS Innovate 2026

Nearly 200 sessions are now available on demand with the SAS Innovate Digital Pass.

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