Hi SAS folks-
Small issue... was doing a quick proc print, used sum to get a grand total, then couldn't figure out how to label it. Anyone know why grandtotal_label is not working here? (Yes, I could do it in another proc, but got interested.)
Thanks!
Wendy
proc print data=sashelp.shoes label noobs grandtotal_label='Total Sales';
id region ;
sum sales ;
where product='Boot' and region like 'A%' ;
run ;
Hi @WendyT
the grand total label is actually displayed in the ‘obs’ column.
To see it, you need to remove the NOOBS option as well as the ID statement.
Best,
proc print data=sashelp.shoes label /*noobs*/ grandtotal_label='Total Sales';
*id region ;
sum sales ;
where product='Boot' and region like 'A%' ;
run ;
Hi @WendyT
the grand total label is actually displayed in the ‘obs’ column.
To see it, you need to remove the NOOBS option as well as the ID statement.
Best,
proc print data=sashelp.shoes label /*noobs*/ grandtotal_label='Total Sales';
*id region ;
sum sales ;
where product='Boot' and region like 'A%' ;
run ;
I think SUMLABEL and GRANDTOTAL_LABEL kick in only when there is a BY group. That's how those options are documented.
proc print data=sashelp.shoes
label noobs sumlabel='Region Sales'
grandtotal_label="TOTAL Sales";
by region ;
sum sales ;
where product='Boot' and region like 'A%' ;
run ;
@ed_sas_member is correct. And...so am I, sort of, with the BY group note. So...take your pick of which approach suits you!
Hi @Reeza - as @ed_sas_member points out, you can use it without BY when the OBS column is displayed. With BY and the SUMLABEL, there's a "Sum" spot allocated so I guess it just renders there. This is probably a function of the ODS template for this in PROC PRINT.
As far as how I read the doc...well, you're right. It doesn't say a BY is needed. I was just thinking like a PROC. "SUMLABEL" is doc'd as needing a BY to display group totals, and a "grand total" is a total of totals...so I just assumed a BY was needed for that too. But I guess not, though it seems to help in some cases 😉
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.