RATS 10.1
RATS 10.1

Instructions /

SELECT Instruction

Home Page

← Previous Next →

SELECT( options )  number

SELECT( options )  number   selectlist
 

SELECT displays a dialog box asking the user to select items from a list of integers, strings, or data series. You can allow the user to make only one choice or many. Note that you can also include selection boxes as an item in DBOX.

Parameters

number

If you use just this one parameter, the user can only select one item from the list, and number will be an integer indicating which it was. The meaning of the return value depends upon the list type­–see the options below.
 

If you use both parameters, the user can select any number of items and number returns the number of items selected.

selectlist

To allow the user to select more than one item, supply a new variable name for the selectlist parameter. RATS will create this variable as a VECTOR[INTEGERS] containing the return values of the selected items.

Options

SERIES

STRINGS=VECTOR of STRINGS to list

LIST=VECTOR of INTEGERS to list

REGRESSORS

These four (mutually exclusive) options determine the type of list displayed:

 

Use SERIES to request a selection from the list of series currently in memory. When you use SERIES, the return values are the series numbers ("handles"). You can use a selectlist array directly in a regression list and other locations where a RATS instruction requests a “list of series.” The special series CONSTANT is never displayed as one of the choices in the list.

STRINGS requests a selection from a list of labels. You must declare and set the VECTOR[STRINGS] before executing SELECT. The return values are the selected positions (element numbers) in the VECTOR[STRINGS].

Use LIST to request a selection from an arbitrary list of integers. You must declare and set the VECTOR[INTEGERS] before executing SELECT. SELECT returns the actual integer values selected (not the positions in the array).

REGRESSORS requests a selection of regressors from the last completed regression. The return values are the selected positions in the list.
 

PROMPT="prompt string"

Use PROMPT to display a message at the top of the dialog box.

 

STATUS=(output) INTEGER variable for status

The STATUS option sets this to 0 if the user cancels the selection and 1 if the user OK’s it. You should always get and check the status.

 

LIMIT=limit on list length

By default, SELECT will (depending upon the option used) list all series in memory or all elements of the VECTOR[STRINGS] or VECTOR[INTEGER]. You can use the LIMIT option to have SELECT display only the first limit items available.

 

For example, the instruction SELECT(SERIES,LIMIT=N) will list only series numbers 1 through N. Note: LIMIT has nothing to do with limiting the number of items the user can select.

 

LIMIT is most useful with the SERIES option, since you may want to restrict the user to choosing only from the original data series, and not derived series like residuals. If you know that there were four original series, with

 

   select(prompt="Graph Which Series",series,limit=4,status=ok) $
     seriesnum
   if ok {

      graph(key=upleft) 1

      # seriesnum

    }

   end if

 

you could ask the user to select one of the first four series.

Example

select(series,prompt="Select Explanatory Variables",status=ok)  $

  nselect reglist

if ok {

  linreg y

  # constant reglist

}

end if
 

This requests the user to select one or more series. The selected variables are then used in a regression.

 


Copyright © 2025 Thomas A. Doan