Tuesday, 25 September 2012

NOTE: Prompts, Beyond the Basics With Enterprise Guide

There's an enormous number of capabilities in Enterprise Guide (EG). I'm not just referring to the wide range of tasks for data manipulation and data analysis, nor the fact that you can type your SAS code or you can drag and drop tasks to make a flow diagram, I'm thinking of capabilities like Prompts. If you want to make your EG projects more flexible and more easily used by those with less SAS skills than yourself then Prompts should interest you.

In brief, Prompts allow you to make your EG project parameter-driven, and the parameter values are requested via a nice, neat dialog box. The dialog box is automatically customised to include the parameters you have included in your Project; it allows the user to input simple text, but can also offer drop-down lists, date pickers and other widgets that make data entry easier for the user.

Prompts are easy to use within your project. They're stored and referred to as macro variables, i.e. you need to remember to prefix the Prompt's name with an ampersand (&) when you use it.

So, let's take things in order: how do we create prompts, where can we use them, and how do we use them?

To create a prompt, use EG's View menu and select Prompt Manager. This will show the Prompt Manager pane. From there, you can click Add; and from the Add New Prompt dialog, you can specify your first Prompt. The dialog is fairly self-explanatory. The key field is "Name", this is the name that you will use in your tasks and code in your Project. The other key field is "Method for populating prompt", this tells EG whether you simply want to allow the user to enter values, whether you want the user to select from a list of values that you have provided, or whether the user shall select from a list of values taken from a data set (this latter option is known as a Dynamic Prompt).

The Prompt Manager is the main focus for creating and editing Prompts, but there is also a button in the Query Builder task dialog.

There's a wide range of places you can use a Prompt. You can use Prompts in queries, tasks, programs and stored processes.

To use a Prompt in a query or task, the opportunity is usually made clear. For example, when offered the opportunity to type a value in Query builder, you're shown a dialog with three tabs: Values, Columns, Prompts. If you use a Prompt within a task or query by typing its name (prefixed with an ampersand) then you'll need to tell EG your intention. You can do this from the Properties of the task or query - you'll see Prompts listed in the left-hand pane of the Properties dialog. Use the same approach for programs, i.e. select the Properties of the program and edit the Prompts pane.

If you would like to know more about Prompts, I recommend you read Angela Hall's excellent SAS Global Forum 2011 paper Creating Reusable Programs by Using SAS Enterprise Guide Prompt Manager.

Prompts are very simple to put into use and to maintain. They provide tremendous flexibility with their choice of differing types, defaults values, etc. And finally, they make your EG Project much more accessible to those with less SAS knowledge than yourself. If you're not already using them, I suggest you take the first opportunity to do so.