Previous Page | Next Page

Examples

Saving Queries

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

[SQL QUERY window]


Saving a Query to Include Later

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

[Saving the query]

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 [arrow] 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 [arrow] 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 [arrow] 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 [arrow] Save Query [arrow] 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 [arrow] 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 [arrow] 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 [arrow] Save Query [arrow] 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 [arrow] List/Include Saved Queries. The queries that you have created are listed in the Saved Queries window.

[List of saved queries]


Including a Saved Query

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

[Clearing the previous query]


Viewing Your Output

You can run SASUSER.PROFILE.EDU20 by selecting Tools [arrow] Run Query [arrow] Run Immediate. The results are displayed in the Output window.

[Query output]

Previous Page | Next Page | Top of Page