SUPPORT / SAMPLES & SAS NOTES
 

Support

Sample 33309: How To Select "All" When Using Parameters in SAS® Enterprise Guide

DetailsAboutRate It

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

  1. Add SASHELP.CLASS to the Project.
  2. Select Tools ► Parameters (Macro Variables) Manager.
  3. Click Add to add a new parameter.
  4. Click the General tab.
  5. For Display name, enter what you want the user to see as a prompt.
  6. For the Data type, choose String.


  7. image label

  8. Click the Data Type and Values tab.
  9. For the Data value type, select A list of values.
  10. Select Load values, and then choose Project.
  11. Select the CLASS data set.
  12. Select Sex from the available columns and click OK. You will now see the Value List populated with "F" and "M".
  13. Add the value "ALL" where it says < Click here to enter values >

    image label

  14. Click Add and Close.
  15. Close out of the Parameter Manager.

Build the Query

  1. Bring up the Query Builder.
  2. Drag all the variables over on the Select Data tab.
  3. Click the Filter Data tab.
  4. Drag SEX over. This will bring up the Edit Filter dialog box.
  5. Keep the default Operator value of Equal to.
  6. Click the down arrow next to the Value drop-down list
  7. . This opens another small window.
  8. Click the Parameters tab and select the parameter that you created earlier.


  9. image label

  10. Click OK to close the dialog box.
  11. Back in the Query Builder, click on the New Filter icon, and select New Advanced Filter.


  12. image label

  13. Type the following into the expression editor, substituting whatever you called your parameter for &selectGender. In this sample, the expression is "&selectGender"="ALL"
  14. Click OK to close the dialog box.
  15. Back in the Query Builder, click Combine Filters.
  16. Change the AND to OR.


  17. image label

  18. 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.