Chapter Contents

Previous

Next
SAS SQL Query Window User's Guide

Designing and Saving a Report

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

In the SQL QUERY window, select SAMPLE.EMPINFO and SAMPLE.SALARY from the list of Available Tables and add them to the list of Selected Tables.

[IMAGE]

Select OK to display the SQL QUERY COLUMNS window. Select Identification Number, DIVISION, Education Level, and Salary from the list of Available Columns.

[IMAGE]

Select

View
[arrow]
Join Type

to create an inner join. Select Matched Join from the Join Types window. Select OK.

Select Identification Number from both columns in the Columns for Setting Join Criteria window.

[IMAGE]

Select OK.


Producing Output with the REPORT Procedure

Select

Tools
[arrow]
Run Query
[arrow]
Design a Report
[arrow]
Begin with default report

The output from your query appears in a PROC REPORT window.

[IMAGE]


Modifying the Format of Your Report

You can now modify your report.

Set Report Options

In the REPORT window, select

Tools
[arrow]
Options
[arrow]
Report

To set the width of the output, in the ROPTIONS window, Type 80 in the Linesize field. Type 60 in the Pagesize field. Select HEADLINE and HEADSKIP.

[IMAGE]

Select OK.

Define Selected Item

Select the Identification Number heading. Select

Edit
[arrow]
Define

Select NOPRINT in the DEFINITION window to prevent the identification number from being displayed.

[IMAGE]

Select OK.

Move Selected Item

In the REPORT window, select Education Level. Select

Edit
[arrow]
Move
[arrow]
Left of next selected item.

Select the DIVISION heading in the REPORT window. Education Level will appear as the first column in the window.

Select the Education Level in the REPORT window. Select

Edit
[arrow]
Define

In the DEFINITION window, select ORDER. Type 2. in the Format field. Type 15 in the Width field. Type CENTER in the Justify field.

[IMAGE]

Select OK.

Select the SALARY heading in the REPORT window. Select

Edit
[arrow]
Move
[arrow]
Left of next selected item

Select the Division heading. Salary will appear as the second column in the window.

Select the Salary heading. Select

Edit
[arrow]
Define

In the DEFINITION window, type DOLLAR8. in the Format field. Type 8 in the Width field.

[IMAGE]

Select OK.

Select the DIVISION heading in the REPORT window. Select

Edit
[arrow]
Define

Type $30. in the Format field of the DEFINITION window. Type 30 in the Width field.

[IMAGE]

Select OK.


The Formatted Report

Your completed report compares the salaries of different divisions for employees with the same education level.

[IMAGE]


Viewing the Report Statements

You can view your report statements in the SOURCE window by selecting

Tools
[arrow]
REPORT Statements

[IMAGE]

Select

File
[arrow]
End

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

File
[arrow]
Save 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.

[IMAGE]

Select OK. A dialog window appears that notifies you of the creation of a new catalog. Select OK.

Select

File
[arrow]
Close

to exit the REPORT window. Select OK in the dialog window 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

Tools
[arrow]
Run Query
[arrow]
Design a Report
[arrow]
Use definition from last Report

The results of the query are presented using your predefined report.


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.