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
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.