SUPPORT / SAMPLES & SAS NOTES
 

Support

Sample 32185: How to Create a Prompt to Select from a List of Values in SAS® Enterprise Guide

DetailsResultsAboutRate It

Overview

SAS Enterprise Guide can be used to create a prompt that enables users to select multiple values from a list. The following steps demonstrate how to create this type of prompt. The sample uses the SASHELP.SHOES data set and creates a parameter that enables users to select multiple regions to report on.

Create the Parameter

  1. Bring the SASHELP.SHOES data set into the project.
  2. Go to Tools→Parameters (Macro Variable) Manager.
  3. Click Add to create a new parameter.
  4. On the General tab, perform these steps:
    • Put the text that you want to appear on your prompt in the Display name field.
    • Either leave the default SAS code name that is created or rename it. This is the name of the macro variable that will be used in the code.
    • Set the Data type to String.

    Parameter General Tab

  5. On the Data Type and Values tab, perform these steps:
    • Leave the Data type as String.
    • Set the value of Data value type to A list of values. This will change the options in your window.
    • In the Options pane, select Allow multiple values. The default separator is a comma.
    • Leave Prompt for value option selected, and also select the Enclose values within quotes option. This option is important because it ensures that your individual macro values will resolve properly.
    • In the Value list select Load values, and then perform these steps:

      • Select Project and then select the SHOES data set. This will bring up a Select Column dialog box.
      • In the dialog box, select Region in order to populate the list of filter choices with all the available regions.
      • Select Column

      • Click OK and you will see all the regions listed in the Value list. If you want to select a default value, you could do that now.
      • Back in the Add New Parameter dialog box, click Add and Close to return to the Parameter Manager.

    Populated Parameter Window

  6. Close the Parameter Manager.
  7. Bring up the Query Builder (Data→Filter and Query).
  8. Add all the variables to the Select Data tab.
  9. Select the Filter Data tab, and drag the Region variable over. This will bring up the Edit Filter dialog box.
  10. Select In a list of values for the Operator. This is important because multiple macro values need to be resolved. If you just use Equals, the macro will not resolve properly.
  11. For the Values choice, click Add and then click on the Parameters tab. Select the parameter you created in the Parameter Manager and click OK.
  12. Filter Selection

  13. Back in the Edit Filter dialog box, deselect the Enclose values in quotes option. If you leave this option selected, then the whole list of macro values will be quoted. Instead, the values must be quoted individually, which is why we chose that option when we created the parameters in the Parameter Manager. Click OK to return to the Query Builder.
  14. Filter Selection

  15. Click Run to close the Query Builder and run the query. You will be prompted to select a region.
  16. Prompt
  17. Select the regions of interest and run the report.

Viewing Results

To see results, click the Results tab at the top of this sample.

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.