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

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 668 views
  • 0 likes
  • 2 in conversation