Create a detail report that has a customized layout. Select specific information to list on each page. Customize the page and column headers by suppressing the default headings and replacing them with customized features.
Supreme Tire and Auto Repair Service Record Bert Allen 1803 Knollton Ct. Bristol, NC 29345 Ford F-150 1998 Hours Labor Parts Total Date Description Worked Cost Cost Cost ---------- --------------- ------ -------- -------- --------- 01/10/2006 replace belts 1.5 $97.50 $0.00 $97.50 10/19/2005 oil change 0.5 $32.50 $18.00 $50.50 ---- -------- ------- --------- 2.0 $130.00 $18.00 $148.00 ---- -------- ------- --------- Labor cost is calculated at $65.00 per hour Total cost = Labor cost + Parts cost ---------------------------------------------page break----------------------------------------------- Supreme Tire and Auto Repair Service Record Bert Allen 1803 Knollton Ct. Bristol, NC 29345 Jeep Cherokee 2000 Hours Labor Parts Total Date Description Worked Cost Cost Cost ---------- --------------- ------ -------- -------- --------- 01/10/2006 replace brakes 2.0 $130.00 $45.00 $175.00 02/20/2006 rotate tires 1.0 $65.00 $20.00 $85.00 transmission 5.5 $357.50 $50.00 $407.50 07/01/2005 oil change 0.5 $32.50 $18.00 $50.50 ---- -------- ------- --------- 9.0 $585.00 $133.00 $718.00 ---- -------- ------- --------- Labor cost is calculated at $65.00 per hour Total cost = Labor cost + Parts cost ---------------------------------------------page break----------------------------------------------- Supreme Tire and Auto Repair Service Record Joe Smith 1991 Cohansey St. New Ulm, NC 29545 Ford F-150 1998 Hours Labor Parts Total Date Description Worked Cost Cost Cost ---------- --------------- ------ -------- -------- --------- 01/19/2006 oil change 0.5 $32.50 $18.00 $50.50 02/25/2006 rotate tires 1.0 $65.00 $0.00 $65.00 ---- -------- ------- --------- 1.5 $97.50 $18.00 $115.50 ---- -------- ------- --------- Labor cost is calculated at $65.00 per hour Total cost = Labor cost + Parts cost ---------------------------------------------page break----------------------------------------------- Supreme Tire and Auto Repair Service Record Sara Jones 202 Stargate Dr. Dart, NC 29445 Chrysler Voyager 2003 Hours Labor Parts Total Date Description Worked Cost Cost Cost ---------- --------------- ------ -------- -------- --------- 12/07/2005 align frontend 1.5 $97.50 $20.00 $117.50 rotate tires 1.0 $65.00 $20.00 $85.00 ---- -------- ------- --------- 2.5 $162.50 $40.00 $202.50 ---- -------- ------- --------- Labor cost is calculated at $65.00 per hour Total cost = Labor cost + Parts cost |
This report shows the service records for cars brought to a car repair shop. A car can have multiple service records, and all the service records for one car are printed on one page. A heading on each page identifies the car and its owner.
Each observation in the SERVICE data set corresponds to one service record on one date for one car. A row in the body of each page of the report corresponds to one observation in SERVICE.
Some variables in the report appear in columns. Others appear only in the page heading. The columns include data set variables and computed variables.
Note that one customer has two cars and that two customers have the same car model.
Many of the features of the main example require that you send the report to a LISTING destination. Modifications to the program that would produce a similar report for a nonlisting destination are described in the Related Technique section.
This report suppresses the default placement of column headings and instead writes column headings with programming statements that are placed in a COMPUTE BEFORE block. The programming statements place the customer information in the upper left corner of the report and write the column headings in specific column positions of the report. The explicit column positioning of the column headings would not work if the report were sent to a nonlisting destination.
The main program for this example writes page and column headings to explicit locations on a page. When you send this report to a nonlisting destination, these instructions are ignored and the formatting of the report is out of alignment.
The following program removes the explicit positioning of data in the headings of the report in the preceding example. It reinstates column headers by removing the NOHEADER option.
The TITLE statements create the page headings, and the BYVAL feature in the TITLE statements customizes these headings. If you tried to write the page headings with a COMPUTE BEFORE block and did not include the PROC REPORT NOHEADER option, PROC REPORT places the column headings before the page headings.
Figure 4.1 shows the first page of the report when sent to the RTF nonlisting destination.
The program that created the output in Figure 4.1 follows.
A Closer Look |
Combining the ORDER and NOPRINT options in the definition of a variable in PROC REPORT provides you with a lot of flexibility for customizing a report.
□ | The ORDER option orders the rows of the report. |
□ | The ORDER option also lets you place customized text at points in the report where the value of that variable changes. |
□ | The NOPRINT option prevents a variable from appearing in a column. NOPRINT has no effect on the ORDER option. A variable defined with both options affects the order of the rows of the report, even though it does not appear in a column of the report. |
The page heading in the main example identifies the car and its owner. This information appears before the first row of repair charges. Variables that do not appear in a column appear in the page heading.
The report is ordered by the car owner’s name and within that by car for customers with more than one car with repair records.
The ORDER option on the DEFINE statements arranges the observations, while the NOPRINT option suppresses their display as columns. The values of these items, however, are still available to the step. The COMPUTE BEFORE CARTYPE block references them and writes the page heading.
The BYLINE/NOBYLINE SAS System Options. See “SAS System Options” in SAS 9.1 Language Reference: Dictionary.
Inserting BY-group information in titles. See “Creating Titles that Contain BY-Group Information” in the “Fundamental Concepts in Using Base SAS Procedures” section of Base SAS 9.1 Procedures Guide.
PROC REPORT reference, usage information, and additional examples. See “The REPORT Procedure” in the “Procedures” section of Base SAS 9.1 Procedures Guide.
3.145.191.214