Examples |
To save the query that you created in the previous example in SASUSER.PROFILE, select Tools Show Query to display the SQL QUERY window.
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.
Type IDWAGE in the Entry Name field. Type ID number and hourly wage in the description field. Select to save your query as an entry in SASUSER.PROFILE and to return to the SQL QUERY window. Select 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
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 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 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 .
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 to clear the WHERE expression.
Select SAMPLE.EMPINFO from the Available Tables list and add it to the Selected Tables list. Select 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 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 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.
Including a Saved Query |
Select SASUSER.PROFILE.EDU20 and select . A dialog box asks whether you want to clear the previous query or include the previous query with the new one. Select .
Viewing Your Output |
You can run SASUSER.PROFILE.EDU20 by selecting Tools Run Query Run Immediate. The results are displayed in the Output window.
Copyright © 2008 by SAS Institute Inc., Cary, NC, USA. All rights reserved.