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