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
Pyrite | Level 9

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
Pyrite | Level 9

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

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 3 replies
  • 324 views
  • 5 likes
  • 3 in conversation