Saving Queries


To save the query that you created in the previous example in SASUSER.PROFILE, select
Tools Show Query
to display the SQL QUERY window.

click to expand

Saving a Query to Include Later

Select
Save Query Save as QUERY to Include later
to save your query to SASUSER.PROFILE or another catalog of your choosing.

click to expand

Type IDWAGE in the Entry Name field. Type ID number and hourly wage in the description field. Select OK to save your query as an entry in SASUSER.PROFILE and to return to the SQL QUERY window. Select Goback to return to the SQL QUERY COLUMNS window.

Saving Several Queries

You can save more than one query and then select from a list of queries that you have saved in the current Query Window session or in a previous Query Window session. In this example, you create and save several queries for later selection from a list of the saved queries.

From the SQL QUERY COLUMNS window, select
View Tables
to return to the SQL QUERY TABLES window.

Remove SAMPLE.WAGE from the Selected Tables list. Select OK to display the SQL QUERY COLUMNS window.

Select Salary from the Available Columns list and add it to the Selected Columns list. Select
View Where Conditions for Subset
to display the WHERE EXPRESSION window.

Select Salary from the Available Columns list. Select GT (greater than) from the list of operators. Select <LOOKUP distinct values> from the Available Columns list. Select $25,000 from the Lookup Values window. Select OK to save your WHERE expression.

Select
View Order By
to display the ORDER BY COLUMNS window. Select Salary from the Available Columns list and add it to the Selected Columns list. Select OK to return to the SQL QUERY COLUMNS window.

In addition to the method of saving queries that was described earlier, you can also select
File Save Query Save as Query to Include later

Type ABOVE25 in the Entry Name field. Type Salaries above $25,000 in the description field. Select OK .

You can also save queries that will be processed against different tables. To create the next query that you will save, select
View Tables
to return to the SQL QUERY TABLES window. Remove SAMPLE.SALARY from the Selected Tables list. If a dialog box appears, then select OK to clear the WHERE expression.

Select SAMPLE.EMPINFO from the Available Tables list and add it to the Selected Tables list. Select OK to display the SQL QUERY COLUMNS window.

Add NAME , DIVISION , and Education Level to the Selected Columns list. Select
View Where Conditions for Subset

Select Education level from the Available Columns list. Select GE (greater than or equal to) from the list of operators. Select <LOOKUP distinct values> , and select 20 from the Lookup Values list. Select OK to return to the SQL QUERY COLUMNS window.

Select
File Save Query Save as Query to Include later

Type EDU20 in the Entry Name field. Type Education level above 20 years in the description field. Select OK to save the query.

Listing Saved Queries

You can now display a list of the queries that you have saved, and include one of the queries. Select
File List/Include Saved Queries

The queries that you have created are listed in the Saved Queries window.

click to expand

Including a Saved Query

Select SASUSER.PROFILE.EDU20 and select OK . A dialog box asks whether or not you want to clear the previous query or include the previous query with the new one. Select OK .

click to expand

Viewing Your Output

You can run SASUSER.PROFILE.EDU20 by selecting
Tools Run Query Run Immediate

The results are displayed in the Output window.

click to expand



SAS 9.1 SQL Query Window. Users Guide
SAS 9.1 SQL Query Window: Users Guide
ISBN: 1590472098
EAN: 2147483647
Year: 2004
Pages: 54
Authors: SAS Institute

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net