Creating Enhanced List and Summary Reports |
Defining Column Attributes |
Assigning Formats In previous lessons, you learned that formats determine how data values appear in SAS output. If you don't specify a format for a variable within the PROC REPORT step, PROC REPORT uses the format that is stored in the data set. If no format is stored in the data set, PROC REPORT uses the default format for that variable type. To assign a format to a specific report column, use the FORMAT= attribute in the DEFINE statement for that column. You can specify any appropriate SAS format or user-defined format.
The variable |
Partial PROC REPORT Output, HTML
Flight | Orig | Dest | Freight | Revenue | |
821 | LGA | LON | 403 | 209 | 150634 |
271 | LGA | PAR | 492 | 308 | 156804 |
271 | LGA | PAR | 366 | 498 | 190098 |
821 | LGA | LON | 345 | 243 | 150634 |
821 | LGA | LON | 248 | 307 | 193930 |
But suppose you want your revenue figures to be formatted with
a dollar sign, commas, and two decimal places, in a total width of
15 positions. To do this, you can assign the DOLLAR15.2 format to
|
|
This is part of the HTML output from the program above. Notice that the format supplies the dollar sign, comma, decimal point, and decimal places. However, because the HTML table column conforms to the width of its contents, assigning the format does not increase the column width beyond the length of the data values. |
Partial PROC REPORT Output, HTML
Flight | Orig | Dest | Freight | Revenue | |
821 | LGA | LON | 403 | 209 | $150,634.00 |
271 | LGA | PAR | 492 | 308 | $156,804.00 |
271 | LGA | PAR | 366 | 498 | $190,098.00 |
821 | LGA | LON | 345 | 243 | $150,634.00 |
821 | LGA | LON | 248 | 307 | $193,930.00 |
By contrast, the monospace SAS listing of the report does display the increased column width. |
|
You can also use FORMAT statements with PROC REPORT. However, the DEFINE statement enables you to specify more than one column attribute at a time. Also, you can use the FORMAT= attribute to define report columns (such as statistics or computed variables) that are not data set variables . |
Copyright © 2002 SAS Institute Inc.,
Cary, NC, USA. All rights reserved.