- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 02-26-2011 01:35 PM
(1170 views)
Experts:
Is it possible to tell SAS to format a numeric value in dollar format without having to specify the w? Sometimes all I want to make sure is to limit the decimal points. If the format is for a cumulative variable (e.g. total payments from a large number of customers), I'm hoping to avoid the trouble of estimating how large the total will be to make sure dollar w.d has enough width.
Thank you!
Is it possible to tell SAS to format a numeric value in dollar format without having to specify the w? Sometimes all I want to make sure is to limit the decimal points. If the format is for a cumulative variable (e.g. total payments from a large number of customers), I'm hoping to avoid the trouble of estimating how large the total will be to make sure dollar w.d has enough width.
Thank you!
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi:
If you just used the format (for the AMOUNT variable) like this:
[pre]
format amount dollar.;
[/pre]
You'd probably see this note in the SAS log:
[pre]
NOTE: At least one W.D format was too small for the number to be printed. The decimal may be shifted by the "BEST"
format.
[/pre]
This might result in something like 'E' notation or scientific notation (1.23E8) being used. However, there's no problem in just specifying a large width. Only the LISTING destination uses the WIDTH for the output. ODS destinations just use the widest column for output reports. Consider the program below.
cynthia
[pre]
data numbers;
infile datalines;
input name $ amount;
return;
datalines;
alan 1.00
barb 123456789.22
carl 2345.33
dana 345.44
;
run;
ods listing close;
ods html file='c:\temp\usebigdollar.html' style=sasweb;
proc print data=numbers;
title 'Note that the table cell for amount does not use the "extra" width of the format';
sum amount;
var name amount;
format amount dollar24.;
run;
ods html close;
[/pre]
If you just used the format (for the AMOUNT variable) like this:
[pre]
format amount dollar.;
[/pre]
You'd probably see this note in the SAS log:
[pre]
NOTE: At least one W.D format was too small for the number to be printed. The decimal may be shifted by the "BEST"
format.
[/pre]
This might result in something like 'E' notation or scientific notation (1.23E8) being used. However, there's no problem in just specifying a large width. Only the LISTING destination uses the WIDTH for the output. ODS destinations just use the widest column for output reports. Consider the program below.
cynthia
[pre]
data numbers;
infile datalines;
input name $ amount;
return;
datalines;
alan 1.00
barb 123456789.22
carl 2345.33
dana 345.44
;
run;
ods listing close;
ods html file='c:\temp\usebigdollar.html' style=sasweb;
proc print data=numbers;
title 'Note that the table cell for amount does not use the "extra" width of the format';
sum amount;
var name amount;
format amount dollar24.;
run;
ods html close;
[/pre]
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for the details, Cynthia. I also forgot that format has nothing to do with storage so it does not hurt to define a large one.