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
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.