Designing and Saving a Report

When you run your query, you can use the REPORT procedure to modify your output.

Sample Tables for Designing and Saving a Report

You will need two of the sample tables to practice using the examples in this section.
If there is an active query in the SQL Query Window, then select Toolsthen selectReset to clear the query. Select OK in the dialog box that appears.
In the SQL QUERY TABLES window, select SAMPLE.EMPINFO and SAMPLE.SALARY from the Available Tables list and add them to the Selected Tables list.
Selecting the SAMPLE.EMPINFO and SAMPLE.SALARY tables
Select OK to display the SQL QUERY COLUMNS window. Add Identification Number, DIVISION, Education level, and Salary to the Selected Columns list.
Selecting columns
Select Viewthen selectJoin Type. Select Matched Join from the Join Types window to create an inner join. Select OK.
Select Identification Number from both lists in the Columns for Setting Join Criteria window.
Setting the join criteria
Select OK.

Producing Output with the REPORT Procedure

Select Toolsthen selectRun Querythen selectDesign a Reportthen selectBegin with default report.
The output from your query appears in a PROC REPORT window.
PROC REPORT window

Modifying the Format of Your Report

Set Report Options

You can now modify your report. In the REPORT window, select Toolsthen selectOptionsthen selectReport.
In the ROPTIONS window, type 80 in the Linesize field to set the width of the output. Type 60 in the Pagesize field. Select the HEADLINE and HEADSKIP check boxes.
ROPTIONS window
Select OK.

Define Selected Item

Select the Identification Number heading. Select Editthen selectDefine.
Select NOPRINT in the DEFINITION window to prevent the identification number from being displayed.
DEFINITION window
Select OK.

Move Selected Item

In the REPORT window, select the Education level heading. Select Editthen selectMovethen selectLeft of the Next Selected Item.
Select the DIVISION heading in the REPORT window. Education Level appears as the first column in the window.
Select the Education level heading in the REPORT window. Select Editthen selectDefine.
In the DEFINITION window, select ORDER. Type 2. in the Format field. Type 15 in the Width field. Type CENTER in the Justify field.
Selecting display options for Education Level column
Select OK.
Select the Salary heading in the REPORT window. Select Editthen selectMovethen selectLeft of the Next Selected Item.
Select the Division heading. Salary will appear as the second column in the window.
Select the Salary heading. Select Editthen selectDefine.
In the DEFINITION window, type DOLLAR8. in the Format field. Type 8 in the Width field.
Selecting display options for the Salary column
Select OK.
Select the DIVISION heading in the REPORT window. Select Editthen selectDefine.
Type $30. in the Format field of the DEFINITION window. Type 30 in the Width field.
Selecting display options for the DIVISION column
Select OK.

The Formatted Report

Your completed report compares the salaries of employees from different divisions who have the same education level.
Finished report

Viewing the Report Statements

You can view your report statements in the SOURCE window by selecting Toolsthen selectREPORT Statements.
Viewing the PROC REPORT statements
Select Filethen selectClose to close the SOURCE window and return to the REPORT window.

Saving Your Report

You can save your customized report to a catalog entry for use with later queries by selecting Filethen selectSave Report to display the SAVE DEFINITION window. Type SAMPLE in the Libname field. Type SQL in the Catalog field. Type SALARY in the Report name field. Type Salaries and Divisions in the Description field.
SAVE DEFINITION window
Select OK. A dialog box appears that notifies you of the creation of a new catalog. Select OK.
Select Filethen selectClose to exit the REPORT window. Select OK in the dialog box that appears.
You can also save your report definition in the SQL Query Window when you save the query.

Use Definition from Last Report

You can use your customized report definition. In the SQL QUERY COLUMNS window, select Toolsthen selectRun Querythen selectDesign a Reportthen selectUse definition from last Report.
The results of the query are presented using your predefined report.
Select Filethen selectClose to exit the REPORT window. Select OK in the dialog box that appears.