BookmarkSubscribeRSS Feed
BrahmanandaRao
Lapis Lazuli | Level 10
data sales;
input salesperson $ January February March ;
datalines;
Smith           1000        650        800
Johnson            0        900        900
Reed            1200        700        850
Davis           1050        900       1000
Thompson         750        850       1000
Peterson         900        600        500
Jones            800        900       1200
Murphy           700        800        700
Garcia           400       1200       1150
;
run;

proc print data=sales noobs sumlabel='Total' grandtotal_label='Grand Total' ;
sum January February March  ;
run;

Anandkvn_0-1641886806159.png

I want to grand_total  using grand_totallabel option but its not give

4 REPLIES 4
Kurt_Bremser
Super User

The label is displayed in the obs number column, so you need to omit the NOOBS option:

proc print
  data=sales
  sumlabel='Total'
  grandtotal_label='Grand Total'
;
sum January February March;
run;

If you want it in the salesperson column, use PROC REPORT:

proc report data=sales;
column salesperson january february march;
define salesperson / display;
define january / sum;
define february / sum;
define march / sum;
rbreak after / summarize;
compute after;
  salesperson = "Grand Total";
endcomp;
run;
BrahmanandaRao
Lapis Lazuli | Level 10
proc sort data=sashelp.class out=class;                                    
   by sex;                                                                 
run;  
                                                             
proc format;                                                               
   value $genderf                                                          
      'F'='Female'                                                         
      'M'='Male';                                                          
run;                                              
                                                                           
proc print data=class noobs                                                
     sumlabel='#byval(sex) Total' grandtotal_label='Grand Total';   
   by sex;                                                                 
   var name age height weight;                                             
   sum height weight;                                                                                                                                 
   format sex $genderf.;                                                   
run;
ballardw
Super User

I generally use a different report procedure, either Tabulate or Report to have more control over things and avoid the sometimes esoteric interactions of the Proc Print options.

 

proc tabulate data=sales;
   class salesperson;
   var January February March;
   table salesperson='' All='Grand Total'  ,
         (January February March)*sum=''*f=best8.
         /box = 'Sales Person'
   ;
run;

Also it seems like as soon as I do the basic report I get asked something like "What is the mean for each Sales person?" which Proc Print won't do.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 4 replies
  • 530 views
  • 1 like
  • 3 in conversation