BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
pavank
Quartz | Level 8
data sales;
    input Region $ Sales;
    datalines;
North 12345
South 67890
East  23456
West  78901
North 34567
South 89012
East  45678
West  12345
;
run;

/* Using PROC MEANS with LABEL and FORMAT */
proc means data=sales mean sum;
    var Sales;
    label Sales = 'Total Sales';
    format Sales comma10.;
    title 'Summary Statistics for Sales';
run;

How to apply label and format statments in proc means procedure

1 ACCEPTED SOLUTION

Accepted Solutions
rudfaden
Lapis Lazuli | Level 10

You cannot directly edit the format of sum and mean. You need to edit the base template.

data sales;
    input Region $ Sales;
    datalines;
North 12345
South 67890
East  23456
West  78901
North 34567
South 89012
East  45678
West  12345
;
run;
ods path(prepend) work.templat(update);
proc template;
 edit base.summary;
  edit mean;
   format=comma10.;
  end;
  edit sum;
   format=comma10.;
  end;
 end;
run;

proc means data=sales mean sum;
    var Sales;
    label Sales = 'Total Sales';
    title 'Summary Statistics for Sales';
run;


proc template;
 delete base.summary;
run;

View solution in original post

3 REPLIES 3
rudfaden
Lapis Lazuli | Level 10

You cannot directly edit the format of sum and mean. You need to edit the base template.

data sales;
    input Region $ Sales;
    datalines;
North 12345
South 67890
East  23456
West  78901
North 34567
South 89012
East  45678
West  12345
;
run;
ods path(prepend) work.templat(update);
proc template;
 edit base.summary;
  edit mean;
   format=comma10.;
  end;
  edit sum;
   format=comma10.;
  end;
 end;
run;

proc means data=sales mean sum;
    var Sales;
    label Sales = 'Total Sales';
    title 'Summary Statistics for Sales';
run;


proc template;
 delete base.summary;
run;
ballardw
Super User

Perhaps a different procedure:

When appearance is an issue look to the report procedures where there are more appearance controls:

proc report data=sales;
   column region sales sales=salessum;
   define region / group;
   define sales/mean format=comma10.2 "Mean Sales";
   define salessum/ sum format=comma10. "Total Sales";
run;

or

proc tabulate data=sales;
   class region;
   var sales;
   table region=' ',
         Sales=' '*(mean='Mean Sales'*f=comma10. sum='Total Sales'*f=comma10.)
         /box='Region'
   ;
run;

or create an output set and us proc print.

pavank
Quartz | Level 8

Hi @ballardw  

Thank you for your solution

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
  • 3 replies
  • 1120 views
  • 6 likes
  • 3 in conversation