Hi Josh,
I know what you mean. When currency amounts are stored as dollar values with fractional cents when a large number of records are aggregated the total can be incorrect. This stems from the fact that 1 cent as .01 cannot be represented accurately in binary (just like 1/3 cant be represented accurately in decimal .333333 recurring). As you suggested a good way to handle this is to store the currency value as an integer number of cents and then format it as a dollar value by dividing by 100 to display it.
The following code shows a sample dollarc format that formats a integer cents value as a dollar and cents amount. This particular sample puts a negative amount in brackets. If you don't want that its easy enough to modify the format.
Here's the sample code:
* a format that displays a cents integer value as a dollar value and negative values in parentheses;
proc format;
picture dollarc
low - <0 = '00,000,000,000,009.99)' (mult=1 prefix='($')
0 - high = '00,000,000,000,009.99 ' (mult=1 prefix='$')
;
run;
data demo;
attrib cost label='Cost' format=dollarc.;
infile cards;
input cost;
cards;
-1234567898
-1234567
-12345
-123
-99
-1
0
1
99
123
12345
1234567
1234567898
;
run;
proc print data=demo label;
run;
... and here's the sample output (it will line up properly when you run it, its just that the discussion forum doesn't let me have preformatted text as far as I know):
Obs Cost
1 ($12,345,678.98)
2 ($12,345.67)
3 ($123.45)
4 ($1.23)
5 ($0.99)
6 ($0.01)
7 $0.00
8 $0.01
9 $0.99
10 $1.23
11 $123.45
12 $12,345.67
13 $12,345,678.98
Cheers
Paul
http://platformadmin.com/