SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Enhancing Reports
Formatting Data Values


Specifying SAS Formats

The table below describes some SAS formats that are commonly used in reports.


Format Specifies values . . . Example
COMMAw.d with commas and decimal places comma8.2
DOLLARw.d with dollar signs and commas dollar6.2
MMDDYYw. as date values in mmddyy order mmddyy6.
w. rounded to the nearest integer in w spaces 7.
w.d rounded to d decimal places in w spaces 8.2


Field Widths

All SAS formats specify the total field width (w) used for displaying the values in the output. For example, suppose that the longest value for the variable Net is a four digit number, such as 5400. To specify the COMMAw.d format for Net, you specify a field width of 5 or more. You must count the comma, because it occupies a position in the output.


format net comma5.0;

5

,

4

0

0

1

2

3

4

5


Decimal Places

For numeric variables you can also specify the number of decimal places (d), if any, to be displayed in the output. Numbers are rounded to the specified number of decimal places. In the example above, no decimal places are displayed.

Writing the whole number 2030 as 2,030.00 requires eight print positions, including two decimal places and the decimal point.


format qtr3tax comma8.2;

2

,

0

3

0

.

0

0

1

2

3

4

5

6

7

8


Formatting 15374 with a dollar sign, commas, and two decimal places requires ten print positions.


format totalsales dollar10.2;

$

1

5

,

3

7

4

.

0

0

1

2

3

4

5

6

7

8

9

10



back||next


Copyright © 2002 SAS Institute Inc., Cary, NC, USA. All rights reserved.

Terms of Use & Legal Information | Privacy Statement