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
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;
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;
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.
Hi @ballardw
Thank you for your solution
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Lock in the best rate now before the price increases on April 1.
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.
Ready to level-up your skills? Choose your own adventure.