Discussion:
SAS Formats w/ proc means
(too old to reply)
Marc Weinmann
2008-10-07 13:25:23 UTC
Permalink
Hi all.
I have a dataset that has 12 numeric fields (among others) that I
would my sums made with proc means to use commas for thousands,
millions, billions, etc. The actual output of my proc means statement
is not using comma formatting, but as written the code compiles/runs
fine.

I tried putting the format statement within my Data step, that works,
but has no affect on the proc means statement. I can tell it works in
an execution sense from proc contents. I tried as below to put the
format in my proc means statement, that too seems to run fine but does
not format the output with commas.

I need a clue if I am trying to do the impossible or missing a simple
concept. How can I format the output of a proc means to use commas and
not have any fractional decimal amounts?


Thanks
Marc


proc means print data=LocData sum;
var RepValBldg RepValOstr RepValCont RepValTime
LimitValBldg LimitValOstr LimitValCont LimitValTime
Ded1 Ded2 Ded3 Ded4;
format RepValBldg RepValOstr RepValCont RepValTime
LimitValBldg LimitValOstr LimitValCont LimitValTime
Ded1 Ded2 Ded3 Ded4 comma16.;
run;


Snippet showing I had successfully set the format on the dataset (output
of proc contents)

20 RepValBldg Num 8 COMMA16.
22 RepValCont Num 8 COMMA16.
21 RepValOstr Num 8 COMMA16.
23 RepValTime Num 8 COMMA16.

My proc means output (without commas)
The MEANS Procedure

Variable Sum
----------------------------
RepValBldg 504885
RepValOstr 5197789
RepValCont 35976020
RepValTime 207403.00
LimitValBldg 5045885
LimitValOstr 5196789
LimitValCont 34576020
LimitValTime 7068562
Ded1 647801
Ded2 0
Ded3 0
Ded4 0
----------------------------
Nat Wooding
2008-10-07 13:47:38 UTC
Permalink
Marc

Proc means does not use format statements for its output. However, if you
use an output statement to create a new data set of the summarized values,
you can print this with proc print and use the formats there.

Nat Wooding
Environmental Specialist III
Dominion, Environmental Biology
4111 Castlewood Rd
Richmond, VA 23234
Phone:804-271-5313, Fax: 804-271-2977



Marc Weinmann
<marc.weinmann.lw
***@STATEFARM.COM> To
Sent by: "SAS(r) SAS-***@LISTSERV.UGA.EDU
Discussion" cc
<SAS-***@LISTSERV.U
GA.EDU> Subject
SAS Formats w/ proc means

10/07/2008 09:25
AM


Please respond to
Marc Weinmann
<marc.weinmann.lw
***@STATEFARM.COM>






Hi all.
I have a dataset that has 12 numeric fields (among others) that I
would my sums made with proc means to use commas for thousands,
millions, billions, etc. The actual output of my proc means statement
is not using comma formatting, but as written the code compiles/runs
fine.

I tried putting the format statement within my Data step, that works,
but has no affect on the proc means statement. I can tell it works in
an execution sense from proc contents. I tried as below to put the
format in my proc means statement, that too seems to run fine but does
not format the output with commas.

I need a clue if I am trying to do the impossible or missing a simple
concept. How can I format the output of a proc means to use commas and
not have any fractional decimal amounts?


Thanks
Marc


proc means print data=LocData sum;
var RepValBldg RepValOstr RepValCont RepValTime
LimitValBldg LimitValOstr LimitValCont LimitValTime
Ded1 Ded2 Ded3 Ded4;
format RepValBldg RepValOstr RepValCont RepValTime
LimitValBldg LimitValOstr LimitValCont LimitValTime
Ded1 Ded2 Ded3 Ded4 comma16.;
run;


Snippet showing I had successfully set the format on the dataset (output
of proc contents)

20 RepValBldg Num 8 COMMA16.
22 RepValCont Num 8 COMMA16.
21 RepValOstr Num 8 COMMA16.
23 RepValTime Num 8 COMMA16.

My proc means output (without commas)
The MEANS Procedure

Variable Sum
----------------------------
RepValBldg 504885
RepValOstr 5197789
RepValCont 35976020
RepValTime 207403.00
LimitValBldg 5045885
LimitValOstr 5196789
LimitValCont 34576020
LimitValTime 7068562
Ded1 647801
Ded2 0
Ded3 0
Ded4 0
----------------------------


CONFIDENTIALITY NOTICE: This electronic message contains
information which may be legally confidential and/or privileged and
does not in any case represent a firm ENERGY COMMODITY bid or offer
relating thereto which binds the sender without an additional
express written confirmation to that effect. The information is
intended solely for the individual or entity named above and access
by anyone else is unauthorized. If you are not the intended
recipient, any disclosure, copying, distribution, or use of the
contents of this information is prohibited and may be unlawful. If
you have received this electronic transmission in error, please
reply immediately to the sender that you have received the message
in error, and delete it. Thank you.
Akshaya
2008-10-07 14:38:29 UTC
Permalink
By default, Means & Summary procedures don't format the values when
they are printed. But as Nat suggested using an Output statement and
create a dataset, there you'll see the values are formatted.

Thanks!
Akshaya
Andre Wielki
2008-10-07 14:18:12 UTC
Permalink
Marc,
there is a way if you go into sas ods template

I have copy the template Base.Summary from sashelp.tmplmst
and the only thing i have add in the definr sum section is
format = comma16.;

HTH
Andre

see here a sample
proc template;
define table Base.Summary;
notes "Summary table for MEANS and
SUMMARY";
dynamic clmpct one_var_name one_var_label
one_var;
column class nobs id type ways (varname) (label) (min) (max)
(range) (n)
(nmiss) (sumwgt) (sum) (mean) (uss) (css) (var) (stddev) (cv)
(stderr
) (t) (probt) (lclm) (uclm) (skew) (kurt) (median) (mode) (q1)
(q3) (
qrange) (p1) (p5) (p10) (p25) (p50) (p75) (p90) (p95)
(p99);
header
h;
define
h;
text "Analysis Variable : " one_var_name " "
one_var_label;
space =
1;
just =
C;
print =
one_var;

spill_margin;

end;
define
class;
vjust =
T;

id;

generic;

blank_internal_dups;

end;
define
nobs;
header = "N
Obs";
vjust =
T;

id;

end;
define
id;
vjust =
T;

id;

generic;

end;
define
type;
header =
"Type";
vjust =
T;

id;

end;
define
ways;
header =
"Ways";
vjust =
T;

id;

end;
define
varname;
header =
"Variable";

id;

generic;

end;
define
label;
header =
"Label";

id;

generic;

end;
define
min;
define header
hmin;
text
"Minimum";
text2
"Min";

end;
header =
hmin;

generic;

end;
define
max;
define header
hmax;
text
"Maximum";
text2
"Max";

end;
header =
hmax;

generic;

end;
define
range;
header =
"Range";

generic;

end;
define
n;
header =
"N";

generic;

end;
define
nmiss;
header = "N
Miss";

generic;

end;
define
sumwgt;
header = "Sum
Wgts";

generic;

end;
define
sum;
header = "Sum";
format = comma16.;

generic;

end;
define
mean;
header =
"Mean";

generic;

end;
define
uss;
define header
huss;
text "Uncorrected
SS";
text2
"USS";

end;
header =
huss;

generic;

end;
define
css;
define header
hcss;
text "Corrected
SS";
text2
"CSS";

end;
header =
hcss;

generic;

end;
define
var;
header =
"Variance";

generic;

end;
define
stddev;
header = "Std
Dev";

generic;

end;
define
cv;
header = "Coeff of
Variation";

generic;

end;
define
stderr;
header = "Std
Error";
parent =
Common.ParameterEstimates.StdErr;

generic;

end;
define
t;
parent =
Common.ParameterEstimates.tValue;

generic;

end;
define
probt;
parent =
Common.ParameterEstimates.Probt;

generic;

end;
define
lclm;
define header
hlclm;
text "Lower " clmpct BEST8. %nrstr("%%/CL for
Mean");
split =
"/";

end;
header =
hlclm;

generic;

end;
define
uclm;
define header
huclm;
text "Upper " clmpct BEST8. %nrstr("%%/CL for
Mean");
split =
"/";

end;
header =
huclm;

generic;

end;
define
skew;
header =
"Skewness";

generic;

end;
define
kurt;
header =
"Kurtosis";

generic;

end;
define
median;
header =
"Median";

generic;

end;
define
mode;
header =
"Mode";

generic;

end;
define
q1;
header = "Lower
Quartile";

generic;

end;
define
q3;
header = "Upper
Quartile";

generic;

end;
define
qrange;
header = "Quartile
Range";

generic;

end;
define
p1;
header = "1st
Pctl";

generic;

end;
define
p5;
header = "5th
Ptcl";

generic;

end;
define
p10;
header = "10th
Pctl";

generic;

end;
define
p25;
header = "25th
Pctl";

generic;

end;
define
p50;
header = "50th
Pctl";

generic;

end;
define
p75;
header = "75th
Pctl";

generic;

end;
define
p90;
header = "90th
Pctl";

generic;

end;
define
p95;
header = "95th
Pctl";

generic;

end;
define
p99;
header = "99th
Pctl";

generic;

end;
required_space =
5;

underline;

overline;

byline;

use_format_defaults;

double_space;

split_stack;

use_name;

order_data;

classlevels;

end;
run;

ods html file="d:\test.html" ;
data w;
set sashelp.class;
weight=weight+ 1000000000;
run;
proc means data=w sum;
var weight;
format weight comma16.;
run;
ods html close;
Post by Nat Wooding
Marc
Proc means does not use format statements for its output. However, if you
use an output statement to create a new data set of the summarized values,
you can print this with proc print and use the formats there.
Nat Wooding
Environmental Specialist III
Dominion, Environmental Biology
4111 Castlewood Rd
Richmond, VA 23234
Phone:804-271-5313, Fax: 804-271-2977
Marc Weinmann
<marc.weinmann.lw
Discussion" cc
GA.EDU> Subject
SAS Formats w/ proc means
10/07/2008 09:25
AM
Please respond to
Marc Weinmann
<marc.weinmann.lw
Hi all.
I have a dataset that has 12 numeric fields (among others) that I
would my sums made with proc means to use commas for thousands,
millions, billions, etc. The actual output of my proc means statement
is not using comma formatting, but as written the code compiles/runs
fine.
I tried putting the format statement within my Data step, that works,
but has no affect on the proc means statement. I can tell it works in
an execution sense from proc contents. I tried as below to put the
format in my proc means statement, that too seems to run fine but does
not format the output with commas.
I need a clue if I am trying to do the impossible or missing a simple
concept. How can I format the output of a proc means to use commas and
not have any fractional decimal amounts?
Thanks
Marc
proc means print data=LocData sum;
var RepValBldg RepValOstr RepValCont RepValTime
LimitValBldg LimitValOstr LimitValCont LimitValTime
Ded1 Ded2 Ded3 Ded4;
format RepValBldg RepValOstr RepValCont RepValTime
LimitValBldg LimitValOstr LimitValCont LimitValTime
Ded1 Ded2 Ded3 Ded4 comma16.;
run;
Snippet showing I had successfully set the format on the dataset (output
of proc contents)
20 RepValBldg Num 8 COMMA16.
22 RepValCont Num 8 COMMA16.
21 RepValOstr Num 8 COMMA16.
23 RepValTime Num 8 COMMA16.
My proc means output (without commas)
The MEANS Procedure
Variable Sum
----------------------------
RepValBldg 504885
RepValOstr 5197789
RepValCont 35976020
RepValTime 207403.00
LimitValBldg 5045885
LimitValOstr 5196789
LimitValCont 34576020
LimitValTime 7068562
Ded1 647801
Ded2 0
Ded3 0
Ded4 0
----------------------------
CONFIDENTIALITY NOTICE: This electronic message contains
information which may be legally confidential and/or privileged and
does not in any case represent a firm ENERGY COMMODITY bid or offer
relating thereto which binds the sender without an additional
express written confirmation to that effect. The information is
intended solely for the individual or entity named above and access
by anyone else is unauthorized. If you are not the intended
recipient, any disclosure, copying, distribution, or use of the
contents of this information is prohibited and may be unlawful. If
you have received this electronic transmission in error, please
reply immediately to the sender that you have received the message
in error, and delete it. Thank you.
--
André WIELKI
INED (Institut National d'Etudes Démographiques)
Service Informatique
133 Boulevard Davout 75980 Paris Cedex 20
mél : ***@ined.fr tél : 33 (0) 1 56 06 21 54
./ ADD NAME=Data _null_,
2008-10-07 13:56:01 UTC
Permalink
Proc means doesn't give you that kind of control. Perhaps if you
modify the template.

Proc tabulate on the other had does allow you to easily specify the
format for any statstic.

%let vars = RepValBldg RepValOstr RepValCont RepValTime LimitValBldg
LimitValOstr LimitValCont LimitValTime Ded1 Ded2 Ded3 Ded4;

data work.sums;
infile cards;
input &vars;
cards;
504885 5197789 35976020 207403.00 5045885 5196789 34576020 7068562
647801 0 0 0
;;;;
run;
proc print;
run;

proc tabulate;
var &vars;
table (&vars),sum*f=comma16.;
run;
Post by Marc Weinmann
Hi all.
I have a dataset that has 12 numeric fields (among others) that I
would my sums made with proc means to use commas for thousands,
millions, billions, etc. The actual output of my proc means statement
is not using comma formatting, but as written the code compiles/runs
fine.
I tried putting the format statement within my Data step, that works,
but has no affect on the proc means statement. I can tell it works in
an execution sense from proc contents. I tried as below to put the
format in my proc means statement, that too seems to run fine but does
not format the output with commas.
I need a clue if I am trying to do the impossible or missing a simple
concept. How can I format the output of a proc means to use commas and
not have any fractional decimal amounts?
Thanks
Marc
proc means print data=LocData sum;
var RepValBldg RepValOstr RepValCont RepValTime
LimitValBldg LimitValOstr LimitValCont LimitValTime
Ded1 Ded2 Ded3 Ded4;
format RepValBldg RepValOstr RepValCont RepValTime
LimitValBldg LimitValOstr LimitValCont LimitValTime
Ded1 Ded2 Ded3 Ded4 comma16.;
run;
Snippet showing I had successfully set the format on the dataset (output
of proc contents)
20 RepValBldg Num 8 COMMA16.
22 RepValCont Num 8 COMMA16.
21 RepValOstr Num 8 COMMA16.
23 RepValTime Num 8 COMMA16.
My proc means output (without commas)
The MEANS Procedure
Variable Sum
----------------------------
RepValBldg 504885
RepValOstr 5197789
RepValCont 35976020
RepValTime 207403.00
LimitValBldg 5045885
LimitValOstr 5196789
LimitValCont 34576020
LimitValTime 7068562
Ded1 647801
Ded2 0
Ded3 0
Ded4 0
----------------------------
Andre Wielki
2008-10-07 15:07:37 UTC
Permalink
Marc, a much readable message as i have viewed my preceeding answer
which was not presenting well due to copy paste
there is a way if you go into sas ods template

I have edit the template Base.Summary from sashelp.tmplmst
and rewritten the modified define element
HTH
Andre


proc template;
edit table Base.Summary;
define
sum;
header = "Sum";
format = comma16.;
generic;
end;
run;

data w;
set sashelp.class;
weight=weight+ 1000000000;
run;
ods html file="d:\test.html" ;
proc means data=w sum;
var weight;
format weight comma16.;
run;
ods html close;

--
André WIELKI
INED (Institut National d'Etudes Démographiques)
Service Informatique
133 Boulevard Davout 75980 Paris Cedex 20
mél : ***@ined.fr tél : 33 (0) 1 56 06 21 54
unknown
2008-10-07 16:22:01 UTC
Permalink
On Tue, 7 Oct 2008 06:25:23 -0700, Marc Weinmann
Post by Marc Weinmann
Hi all.
I have a dataset that has 12 numeric fields (among others) that I
would my sums made with proc means to use commas for thousands,
millions, billions, etc. The actual output of my proc means statement
is not using comma formatting, but as written the code compiles/runs
fine.
I tried putting the format statement within my Data step, that works,
but has no affect on the proc means statement. I can tell it works in
an execution sense from proc contents. I tried as below to put the
format in my proc means statement, that too seems to run fine but does
not format the output with commas.
I need a clue if I am trying to do the impossible or missing a simple
concept. How can I format the output of a proc means to use commas and
not have any fractional decimal amounts?
Thanks
Marc
proc means print data=LocData sum;
var RepValBldg RepValOstr RepValCont RepValTime
LimitValBldg LimitValOstr LimitValCont LimitValTime
Ded1 Ded2 Ded3 Ded4;
format RepValBldg RepValOstr RepValCont RepValTime
LimitValBldg LimitValOstr LimitValCont LimitValTime
Ded1 Ded2 Ded3 Ded4 comma16.;
run;
Snippet showing I had successfully set the format on the dataset (output
of proc contents)
20 RepValBldg Num 8 COMMA16.
22 RepValCont Num 8 COMMA16.
21 RepValOstr Num 8 COMMA16.
23 RepValTime Num 8 COMMA16.
My proc means output (without commas)
The MEANS Procedure
Variable Sum
----------------------------
RepValBldg 504885
RepValOstr 5197789
RepValCont 35976020
RepValTime 207403.00
LimitValBldg 5045885
LimitValOstr 5196789
LimitValCont 34576020
LimitValTime 7068562
Ded1 647801
Ded2 0
Ded3 0
Ded4 0
----------------------------
There have been several good suggestions; I favor the one recommending PROC
TABULATE.

Now here's *why* formats for the analysis variables (RepValBldg etc.) do not
work as Marc expected. PROC MEANS is not displaying values of those
variables. Rather it is displaying statistics calculated from the analysis
variables, and those statistics do not inherit formats. PROC MEANS does
provide some control over the display via the FW= and MAXDEC= options, and
there probably ought to be a COMMA/NOCOMMA option to complement those, but
there isn't.

Loading...