How do you display values in dollar format in SAS?

The DOLLARX w.d format in SAS can be used to display numerical values in dollar format. The w represents the total width of the output and the d represents the number of decimal places. The output will include the leading dollar sign, commas to separate thousands, and a decimal point for cents. For example, the number 1234.5678 can be formatted as DOLLAR8.2 to display as $1,234.57.


You can use the DOLLAR format option in SAS to print values in a column formatted as dollars with:

  • A leading dollar sign
  • Commas that separate every three digits
  • A period that separates the decimal fraction

The following example shows how to use the DOLLAR format option in practice.

Example: Display Values in Dollar Format in SAS

Suppose we have the following dataset in SAS that contains information about the price of various products at some store:

/*create dataset*/
data my_data;
    input product $ price;
    datalines;
A 4134.50
B 13499.95
C 14695.99
D 1640.00
E 459.93
F 23.29
G 1005.38
;
run;

/*view dataset*/
proc print data=my_data;

Suppose we would like to format the values in the price column using a dollar format.

We can use the following syntax to do so:

/*view dataset and display price variable in dollar format*/
proc print data=my_data;
    format price dollar10.2;
run;

SAS dollar format

Each value in the price column is displayed in a dollar format.

When using the dollar10.2 statement, the 10 specifies that a maximum of 10 characters will be needed to display the entire string including the dollar sign, commas and decimal place while the 2 specifies that 2 digits should be shown after the decimal place.

If you don’t want to display any values after the decimal place, you can use dollar8.0 instead:

/*view dataset and display price variable in dollar format without decimal places*/
proc print data=my_data;
    format price dollar8.0;
run;

SAS dollar format with no values after decimal place

Notice that each value in the price column is rounded to the nearest dollar and each value after the decimal place has been truncated.

The following tutorials explain how to perform other common tasks in SAS:

x