Sample 33309: How To Select "All" When Using Parameters in SAS® Enterprise Guide
Overview
When using parameters to filter data, you might want to see a certain value, or you might want to see all the values. For example, you might want to filter on Males or Females, or you might want to see results for both. This sample will show you how to get these results using SAS Enterprise Guide 4.1. The SASHELP.CLASS data set is used as the sample data.
Define the Parameter
- Add SASHELP.CLASS to the Project.
- Select Tools ► Parameters (Macro Variables) Manager.
- Click Add to add a new parameter.
- Click the General tab.
- For Display name, enter what you want the user to see as a prompt.
- For the Data type, choose String.
- Click the Data Type and Values tab.
- For the Data value type, select A list of values.
- Select Load values, and then choose Project.
- Select the CLASS data set.
- Select Sex from the available columns and click OK.
You will now see the Value List populated with "F" and "M".
- Add the value "ALL" where it says < Click here to enter values >
- Click Add and Close.
- Close out of the Parameter Manager.
Build the Query
- Bring up the Query Builder.
- Drag all the variables over on the Select Data tab.
- Click the Filter Data tab.
- Drag SEX over. This will bring up the Edit Filter dialog box.
- Keep the default Operator value of Equal to.
- Click the down arrow next to the Value drop-down list
. This opens another small window.
- Click the Parameters tab and
select the parameter that you created earlier.
- Click OK to close the dialog box.
- Back in the Query Builder, click on the New Filter icon, and select New Advanced Filter.
- Type the following into the expression editor, substituting whatever you called your parameter for &selectGender. In this sample, the expression is "&selectGender"="ALL"
- Click OK to close the dialog box.
- Back in the Query Builder, click Combine Filters.
- Change the AND to OR.
- The query is now ready to run.
Note: This sample was created in SAS Enterprise Guide 4.1. SAS Enterprise Guide 4.2 has a built-in option to select all values.
Additional Documentation
For a list of available documentation for SAS Enterprise Guide, see http://support.sas.com/documentation/onlinedoc/guide/.
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
When using parameters to filter data, you might want to see a certain value, or you might want to see all the values. This sample will show you how to get these results using SAS Enterprise Guide 4.1.
Date Modified: | 2008-09-22 10:57:39 |
Date Created: | 2008-09-15 16:53:45 |
Operating System and Release Information
SAS System | SAS Enterprise Guide | Microsoft® Windows® for x64 | 4.1 | | 9.1 TS1M3 SP4 | |
Microsoft Windows 2000 Advanced Server | 4.1 | | 9.1 TS1M3 SP4 | |
Microsoft Windows 2000 Datacenter Server | 4.1 | | 9.1 TS1M3 SP4 | |
Microsoft Windows 2000 Server | 4.1 | | 9.1 TS1M3 SP4 | |
Microsoft Windows 2000 Professional | 4.1 | | 9.1 TS1M3 SP4 | |
Microsoft Windows NT Workstation | 4.1 | | 9.1 TS1M3 SP4 | |
Microsoft Windows Server 2003 Datacenter Edition | 4.1 | | 9.1 TS1M3 SP4 | |
Microsoft Windows Server 2003 Enterprise Edition | 4.1 | | 9.1 TS1M3 SP4 | |
Microsoft Windows Server 2003 Standard Edition | 4.1 | | 9.1 TS1M3 SP4 | |
Microsoft Windows XP Professional | 4.1 | | 9.1 TS1M3 SP4 | |
Windows Vista | 4.1 | | 9.1 TS1M3 SP4 | |