Working with the Options Element

About the Options Element

The Options element identifies the options that are required in order to run the task. The Option tag, which is the only child of the Options element, describes the assigned option.
Attribute
Description
name
Specifies the name assigned to this option.
defaultValue
Specifies the initial value for the option.
inputType
Specifies the input control for this option. Here are the valid values:
  • checkbox
  • color
  • combobox
  • inputtext
  • modelbuilder
  • numstepper
  • radio
  • slider
  • string
  • validationtext
For more information, see Supported Input Types.
indent
Specifies the indention for this option in the task interface. Here are the valid values:
  • 1 – minimal indention (about 17px)
  • 2 – average indention (about 34px)
  • 3 – maximum indention (about 51px)

Supported Input Types

checkbox

This input type does not have additional attributes. The valid values for checkbox are 0 (unchecked) and 1 (checked).
The code in the sample task definition creates two check boxes.
<Option name="GROUP1" inputType="string">CHECK BOXES</Option>
<Option name="chkCheck defaultValue=1" inputType="checkbox">
   Enable another field</Option>
<Option name="chkEXAMPLE" defaultValue="0" inputType="checkbox">
   Check box</Option>
When you run the code, here is the user interface that is created:
Example of check boxes in the sample task definition

color

This input type does not have additional attributes. Here is an example from the sample task definition:
<Option name="colorEXAMPLE defaultValue="gray" 
   inputType="color">Choose Color</Option>
When you run the code, here is the user interface that is created:
Option for selecting a color

combobox

This input type has one attribute.
Attribute
Description
width
Specifies the width of the control. This value can be in percent (%), em, or px. By default, SAS Studio sizes the control based on the available width and content.
The code in the sample task definition creates a combination box called Drop-down list. This list contains three options: Value 1, Value 2, and Value 3.
<Option name="comboEXAMPLE" defaultValue="value2" inputType="combobox">
   Drop-down list:</Option>
<Option name="value1" inputType="string">Value 1</Option>
<Option name="value2" inputType="string">Value 2</Option>
<Option name="value3" inputType="string">Value 3</Option>
When you run the code, here is the resulting user interface:
Default value drop-down list

inputtext

This input type has these attributes:
Attribute
Description
required
Specifies whether any input text is required. Valid values are true and false. The default is false.
missingMessage
Specifies the tooltip text that appears when the text box is empty but input text is required. No message is displayed by default.
promptMessage
Specifies the tooltip text that appears when the text box is empty and the user has selected the text box.
width
Specifies the width of the control. This value can be in percent (%), em, or px. By default, SAS Studio sizes the control based on the available width and content.
The code in the sample task definition creates a text box called Indented field with default value. The default value for this option is output.xls. If the user removes this text, the message “Enter a filename” appears because a valid filename is required.
<Option name="txtEXAMPLE" defaultValue="output.xls" inputType="inputtext" 
   width="100%"
   indent="1"
   required="true"
   promptMessage="Enter a filename"
   missingMessage"Missing filename">Indented field with default value:</Option>
When you run the code, here is the user interface that is created:
Indented field with default value text box

modelbuilder

A model is an equation that consists of a dependent or response variable and a list of effects. The user creates the list of effects from variables and combinations of variables.
Here are examples of effects:
main effect
For variables Gender and Height, the main effects are Gender and Height.
interaction effect
For variables Gender and Height, the interaction is Gender * Height. You can have two-way, three-way, ...n-way interactions.
The order of the variables in the interaction is not important. For example, Gender * Height is the same as Height * Gender.
polynomial effect
You can create polynomial effects with continuous variables. For the continuous variable X, the quadratic polynomial effect is X*X. You can have second-order, third-order, ...nth-order polynomial effects.
The modelbuilder input type has these attributes:
Attribute
Description
required
Specifies whether any input text is required. Valid values are true and false. The default is false.
roleContinuous
Specifies the role that contains the continuous variables. The default value is null.
roleClassification
Specifies the role that contains the classification variables. The default value is null.
excludeTools
Specifies the effect and model buttons to exclude from the user interface. Valid values are ADD, CROSS, NEST, TWOFACT, THREEFACT, FULLFACT, NFACTORIAL, POLYEFFECT, POLYMODEL and NFACTPOLY. Separate multiple values with spaces or commas.
width
Specifies the width of the control. The width value can be specified in percent, em, or px. By default, the control is automatically sized based on the available width and content.
Note: At least one of the role attributes (roleContinuous or roleClassification) is required. If both attributes are set to null, no variables are available to create the model.
Here is some example code for the model builder from the Generalized Linear Model task:
<Option excludeTools="THREEFACT,NFACTPOLY" inputType="modelbuilder"
   name="modelbuilder" roleClassification="classVariables" 
   roleContinuous="continuousVariables" 
   width="100%">Model</Option>
Example of a Model Effects Builder
After selecting an input data source and identifying the columns that contain the continuous or classification variables, you can start building your model. This example uses the Sashelp.Cars data set as the input data source. MSRP, EngineSize, Invoice, and Cylinders are the continuous variables.
Example of Creating Model Effects in the Model Effects Builder

numstepper

This input type has these attributes:
Attribute
Description
decimalPlaces
Specifies the number of decimal places to display. Valid values include a single value or a range. To create a field that allows 0 to 3 decimal places, specify decimalPlaces=”0,3”.
increment
Specifies the number of values that the option increases or decreases when a user clicks the up or down arrow. The default value is 1.
maxValue
Specifies the maximum value that is allowed. If the user tries to exceed this value, a message appears. The default value is 9000000000000.
minValue
Specifies the minimum value that is allowed. If the user specifies a value that is below the minimum value, a message appears.
required
Specifies whether a value is required. Valid values are true and false. The default value is false.
width
Specifies the width of the control. This value can be in percent (%), em, or px. By default, SAS Studio sizes the control based on the available width and content.
The first example in the sample task definition creates an option with an assigned default value of 5.
<Option name="labelNumStepperEXAMPLE1" inputType="string">
   Numeric stepper with default values:</Option>
<Option name="basicStepperEXAMPLE" defaultValue="5" inputType="numstepper"
   indent="1">Label:</Option>
When you run this code, here is the resulting user interface:
Numeric stepper with default values option
The second example in the sample task definition creates an option with a specified minimum value, maximum value, and increment.
<Option name="labelNumStepperEXAMPLE2" inputType="string">
   Numeric stepper with a minimum value of -10, a maximum value of 120, and 
   an increment of 2.</Option>
<Option name="advancedStepperEXAMPLE" defaultValue="80" inputType="numstepper" 
   increment="2"
   minValue="-10"
   maxValue="120"
   decimalPlaces="0,2"
   size="8em"
   indent="1">Label:</Option>
When you run the code, here is the resulting user interface:
Numeric stepper with a minimum value of –10, a maximum value of 120, and an increment of 2

radio

This input type has one attribute:
Attribute
Description
variable
Specifies a variable that contains the name of the currently selected radio button.
The second example in the sample task definition creates an option called Radio button group label with the Radio button 1 button selected by default.
<Option name="labelEXAMPLE2" inputType="string">Radio button group label:</Option>
<Option name="radioButton1" variable="radioEXAMPLE" defaultValue="radioButton1"
   inputType="radio">Radio button 1</Option>
<Option name="radioButton2" variable="radioEXAMPLE" 
   inputType="radio">Radio button 2</Option>
<Option name="radioButton3" variable="radioEXAMPLE" 
   inputType="radio">Radio button 3</Option>
When you run the code, here is the resulting user interface:
Radio button group label with three radio buttons

slider

This input type has these attributes:
Attribute
Description
discreteValues
Specifies the number of discrete values in the slider. For example, if discreteValues=3, the slider has three values: a minimum value, a maximum value, and a value in the middle.
maxValue
Specifies the maximum value for this option.
minValue
Specifies the minimum value for this option.
showButtons
Specifies whether to show the increase and decrease buttons for the slide. Valid values are true and false. The default value is true.
The first example in the sample task definition creates a slider option with buttons.
<Option name="labelSliderEXAMPLE1" inputType="string">
      Slider with buttons.</Option>
<Option name="labelSliderEXAMPLE1" defaultValue="80.00" 
   inputType="slider" discreteValues="14" minValue="-10"
   maxValue="120">Label</Option>
When you run the code, here is the resulting user interface:
Example of a slider with buttons
The second example in the sample task definition creates a slider option without buttons.
<Option name="labelSliderEXAMPLE2" 
   inputType="string">Slider without buttons.</Option>
<Option name="labelSliderEXAMPLE2" defaultValue="80.00" 
   inputType="slider" discreteValues="14" minValue="-10"
   maxValue="120" showButtons="false">Label</Option>
When you run the code, here is the resulting user interface:
Example of a slider without buttons

string

This input type has no attributes. The code for the sample task definition contains several examples of the string input type. In the code for the slider option, the explanatory text (Slider with buttons) is created by the string input type.
<Option name="labelSliderEXAMPLE1" inputType="string">
   Slider with buttons.</Option>
<Option name="labelSliderEXAMPLE1" defaultValue="80.00" 
   inputType="slider" discreteValues="14" minValue="-10"
   maxValue="120">Label</Option>
When you run the code, here is the resulting user interface:
Example of a slider with buttons

validationtext

This input type has these attributes:
Attribute
Description
required
Specifies whether any input text is required. Valid values are true and false. The default is false.
invalidMessage
Specifies the tooltip text to display when the content in the text box is invalid. By default, no message is displayed.
missingMessage
Specifies the tooltip text that appears when the text box is empty but text is required. By default, no message is displayed.
promptMessage
Specifies the tooltip text that appears when the text box is empty and the text box is selected. By default, no message is displayed.
regExp
Specifies the regular expression pattern to use for validation. This syntax comes directly from JavaScript Regular Expressions.
width
Specifies the width of the control. This value can be in percent (%), em, or px. By default, SAS Studio sizes the control based on the available width and content.
The code for the sample task definition creates a text box called Label.
<Option name="validationTextExample" defaultValue="99999"
   inputType="validationtext"
   required="true"
   width="100%"
   promptMsg="A message that tells the user what type of value to enter"
   invalidMsg="Invalid value message"
   missingMsg="This value is required."
   regExp="\d{5}">Label:
</Option>
When you run the code, here is the resulting user interface:
Example of option with validation text
If you remove the default value from this box, the This value is required message appears.
Example of “This value is required” message for a text box
When the user begins entering a value, this message appears: A message that tells the user what type of value to enter.
Example of text that could appear when user starts entering values into the text box
If the specified value is invalid, the Invalid value message appears.
Example of “Invalid value message” for a text box