SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
ssitharath0420
Quartz | Level 8

Hello, I am trying to relable my column and name the sum label to total instead of blank in the proc print statement but it doesn't seem to be working.  What am I missing?

 

proc print data=work.Table1_Final noobs sumlabel='Total';
sum P1 P2 P3 P4;
title "TABLE 1: # of Members Filling Opioids";
label p1='7/1/20 - 12/31/2020'
label p2='4/1/20 - 09/30/2020'
label p3='1/1/20 - 06/30/2020'
label p4='10/1/19 - 03/31/2020';
run;

2 REPLIES 2
ballardw
Super User

SUMLABEL from the documentation:

SUMLABEL

NOSUMLABEL

SUMLABEL='label'

specifies whether to display a label on the summary line for a BY group.

So without a BY statement has no effect.

You have a couple of options, one would be to add a dummy variable to use as a "by" variable so  sum label works.

Another would be to move to Proc Report which has a more robust set of text controls.

Choices can depend on what other variables are in your data and need to be displayed.

I might guess that you manually summarized the data to get your P1 to P4 variables. That could likely be done directly in a report procedure like Proc Report or Tabulate from raw data as long as you have a date variable.

Reeza
Super User

You may need to add the LABEL option in PROC PRINT as well. 

 

proc print data=work.Table1_Final noobs sumlabel='Total' label;

@ssitharath0420 wrote:

Hello, I am trying to relable my column and name the sum label to total instead of blank in the proc print statement but it doesn't seem to be working.  What am I missing?

 

proc print data=work.Table1_Final noobs sumlabel='Total';
sum P1 P2 P3 P4;
title "TABLE 1: # of Members Filling Opioids";
label p1='7/1/20 - 12/31/2020'
label p2='4/1/20 - 09/30/2020'
label p3='1/1/20 - 06/30/2020'
label p4='10/1/19 - 03/31/2020';
run;


 

sas-innovate-wordmark-2025-midnight.png

Register Today!

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.


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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 550 views
  • 0 likes
  • 3 in conversation