SAS OnlineTutor HomeFAQ PageSuggested Learning PathContents+Searchback||next

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.


Example

The variable Revenue has no format assigned to it in the Flights.Europe data set. So, in your current report, revenue values appear as shown in the example below.

Partial PROC REPORT Output, HTML

Flight Orig Dest Mail 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 Revenue.


proc report data=flights.europe nowd; where dest in ('LON','PAR'); column flight orig dest mail freight revenue; define revenue / format=dollar15.2; run;

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 Mail 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.

Partial PROC REPORT Output, SAS Listing
 Fli
 ght
  Ori
  g
  Des
  t
Mail 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 


Note: 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 .

back||next


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

Terms of Use & Legal Information | Privacy Statement