Function Reference: U
@uidialog Display a dialog with multiple controls.
@uiedit Display a dialog with an edit control.
@uilist Display a dialog with a listbox control.
@uimlist Display a dialog with a multiple-select listbox control.
@uiradio Display a dialog with radio buttons.
@uniquevals Vector or svector of unique values of object.
@unvec Unstack vector into a matrix.
@unvech Unstack vector into lower triangle of sym.
@upper Uppercase representation of a string; or upper triangular matrix of a matrix.
@utc Convert local time to UTC (Coordinated Universal Time).
Display user dialog with multiple controls.
Syntax: @uidialog(spec1[, spec1, [spec3, [...])
spec#: string
Return: integer
Displays a dialog with any number of controls that you define, including edit fields, listboxes, radio buttons, checkboxes, text, and captions. You may specify an combination of controls, and they will be arranged in the order they are entered. EViews attempts to lay the controls out in a visually pleasing manner, and will do its best to size and arrange the dialog accordingly.
Each cinfo# item is a specification of the control type in quotes (“Edit”), followed by appropriate parameters. You may specify any combination of controls, where each should follow one of the following forms:
Edit field | “Edit”, IO_String, prompt_string[, max_edit_length] |
Listbox | “List”, IO_StringOrScalar, prompt_string, list_string |
Radio buttons | “Radio”, IO_Scalar, prompt_string, list_string |
Checkbox | “Check”, IO_Scalar, prompt_string |
Text | “Text”, text_string |
Caption | “Caption”, caption_string |
Column break | “Colbreak” |
OK Button | “Button”, button_string |
Cancel Button | “Buttonc”, button_string |
In the above table, the parameters can be described as:
IO_String | string used to initialize an edit field and hold the final edit field text. |
IO_Scalar | scalar used to initialize a radio or checkbox selection, and hold the final selection. |
IO_StringOrScalar | string or scalar used to initialize a listbox selection, and hold the final selection. |
prompt_string | string used as the label for the control, or the groupbox label for radio buttons. |
max_edit_length | scalar for the maximum characters allowed in an edit field. |
list_string | space delimited list of entries for a listbox or radio buttons. |
text_string | text to be used in a text control. |
caption_string | text to be used as the caption of the dialog in its titlebar. |
button_string | text to be used on the button. |
Note that parameters whose names begin with “IO_”, e.g. “IO_String” should be passed into the function using replacment variables or objects in the workfile, as they are used to return results.
The “button” and “buttonc” controls add a custom button to the dialog. The dialog will close after a button has been pressed. The behavior of the button will depend on the type of button —buttons of type “button” will behave in the same way as the “OK” button (i.e., all variables passed into the dialog will be updated to reflect changes made to their corresponding controls). Buttons of type “buttonc” will behave in the same way as the “Cancel” button (i.e., all variables will be reset to the values that were passed into the dialog).
The return value of the dialog will correspond to the order in which buttons are placed in the dialog. If only one button (apart from the standard “OK” and “Cancel”) is included in the dialog, the return value for that button will be “1”. If there is more than one button, then the first button will return a value of “1”, the second will return a value of “2” and so on. Note that the return value is independent of whether the button was of type “button” or “buttonc”. The specification for the button controls is (“button[c]”, “text”) where text specifies the text that will be on the button.
Examples
scalar dinner = 2
string dinnerPrompt = "Choose dinner"
string menu = """Chicken Marsala"" ""Beef Stew"" Hamburger Salad"
string name
string namePrompt = "Enter your name"
scalar result = @uidialog("Caption", "Dinner Menu", "Edit", name, namePrompt, 64, "Radio", dinner, dinnerPrompt, menu)
These commands display a dialog with an edit field and four radio buttons labeled “Chicken Marsala”, “Beef Stew”, “Hamburger”, and “Salad”. The title “Enter your name” appears above the edit field, while the groupbox surrounding the radio buttons is labeled “Choose dinner”. The words “Dinner Menu” appear in the caption area, or titlebar, of the dialog. The edit field is initially blank, since we did not assign any text to the string NAME. The dinner selection radio buttons are initialized with the value 2, so the “Beef Stew” radio will be selected. We limit the name length to 64 characters.
string introString = "We have many pieces to suit your style."
string clothesList = "Shirt Pants Shoes Hat Tie"
string listTitle = "Please make a selection"
scalar selection = 3
@uidialog("text", introString, "list", selection, listTitle, clothesList)
This creates a dialog with a text string and a listbox. The text “We have many pieces to suit your style” appears at the top. A listbox follows, with the label “Please make a selection” and the options: “Shirt”, “Pants”, “Shoes”, “Hat”, and “Tie”. The listbox is initialized to the third item, “Shoes”. If the user then selects the first item, “Shirt”, from the listbox and presses OK, the scalar SELECTION will hold the value 1.
Note that the text control can be used to help achieve the layout you desire. You can use it to insert empty text strings to add space between adjacent controls. For example,
scalar a = 1
scalar b = 0
@uidialog("check", a, "Option 1", "text", "", "check", b, "Option 2")
will leave a space between the two checkboxes. In more complicated dialogs, this may also push the latter controls to a second column. You may have to experiment with the appearance of more complex dialogs.
Cross-references
See
“User-Defined Dialogs” for additional discussion.
For a detailed description of each control type, see
@uiedit,
@uilist,
@uiprompt,
@uiradio.
Displays a dialog with an edit field.
Syntax: @uiedit(arg, prompt[, maxlen])
input: string object, replacement variable
prompt: string
maxlen: (optional) integer
Return: integer
Displays a dialog with an edit field and prompt string that will be used to label the edit field.
• arg is generally entered as a replacement variable or an object in your workfile as it is used to return results. arg is used to initialize the edit field and will contain the value after editing.
• prompt may be specified using in-line text.
• maxlen is an optional maximum character length of the edit field. The default maximum length is 32 characters.
The dialog shows an OK and Cancel button, and will return an integer representing the button clicked: Cancel (-1), OK (0).
Examples
string name = "Joseph"
@uiedit(name, "Please enter your First Name:")
These commands display a dialog with the text “Please enter your First Name:” followed by an edit field, initialized with the string “Joseph”. If the user edits the string to read “Joe” and presses the OK button, the dialog returns a value of 0 and NAME will now contain the string: Joe.
Similarly,
@uiedit("", "Please enter your age:", 2)
brings up a dialog with the prompt “Please enter your age” and an empty edit field with a maximum length of two characters. The user will not be able to enter more than two characters into the edit field.
Cross-references
Displays a standard Windows file open or save dialog
Syntax: @uifiledlg(input, filter, type)
input: string object, replacement variable
filter: string
type: string
Return: integer
Displays a file open/save style dialog.
• input should be either a replacement variable or a string object in your workfile as it is used to return results. input is used to provide an initial location and possibly a name of the file, and will contain the dialog specified value on return.
• filter specifies the name extensions of variables to show, with, for example, “” used to denote all files, and “prg” used to limit the display to files ending in “.prg”
• type determines whether the shown dialog has an “open” or a “save” title.
Both filter and type may be specified using in-line text.
Note that the clicking on the dialog does not actually open or save the selected file, it merely returns the name of the selected file. Thus, specifying the type argument is simply cosmetic.)
The displayed dialog will display both an and a button, and will return an integer representing the button clicked: Cancel (-1), OK (0).
Examples
string myfile = "c:\temp\"
@uifiledlg(myfile, "prg", "open")
These commands display a file open dialog style containing a list of all files with a “.prg” extension in the folder “c:\temp\”. The user can navigate through the file system and select another file, whose path and name will be returned in the string MYFILE.
Note that the slightly different set of commands
string myfile = "c:\temp"
@uifiledlg(myfile, "prg", "save")
will instead display a save dialog that opens in the “c:\” folder with the filename initialized to “temp.prg” (since MYFILE does not have the trailing “\”).
Leaving the filename argument blank on input will open the dialog in the default EViews directory:
string myfile = ""
@uifiledlg(myfile, "", "save")
opens a save dialog in the default EViews directory with no filtering and no default file.
Cross-references
Displays a dialog with a listbox.
Syntax: @uilist(arg, prompt, items)
arg: scalar, program variable, string, replacement variable
prompt: string
items: string
Return: integer
Displays a dialog with a listbox and prompt string that will be used to label the listbox.
• arg should be an object or program variable as it is used to return results. arg is used to provide an initial selection, and will contain the dialog specified value on return.
• prompt specifies the text used to label the listbox.
• items is a space delimited list of items in the listbox.
Both prompt and items may be specified using in-line text.
The dialog shows an OK and Cancel button, and will return an integer representing the button clicked: Cancel (-1), OK (0).
Examples
string selection = "Item2"
@uilist(selection, "Please select an item:", "Item1 Item2 Item3")
These commands display a dialog with a listbox containing the items “Item1”, “Item2”, and “Item3”. The title “Please select an item:” appears above the listbox, and the second item is initially selected. If the user selects the third item and presses OK, the string SELECTION will contain “Item3”, and the dialog will return the value 0.
Similarly,
scalar sel = 3
@uilist(sel, "Please select an item:", "Item1 Item2 Item3")
brings up the same dialog with the third item selected. The scalar SEL will contain the user’s selection if OK is pressed.
Cross-references
Displays a dialog with a multiple-selection listbox.
Syntax: @uimlist(arg, prompt, items)
arg: vector
prompt: string
items: string
Return: integer
Displays a dialog with a listbox and prompt string that will be used to label the listbox.
• arg should be an vector object as it is used to return results. arg is used to provide initial selections, and will contain the dialog specified values on return. On intialization and return arg should contain the index values of the items in the listbox that are selected. If no items are selected arg will be a one element vector containing the value -1.
• prompt specifies the text used to label the listbox.
• items is a space delimited list of items in the listbox.
Both prompt and items may be specified using in-line text.
The dialog shows an OK and Cancel button, and will return an integer representing the button clicked: Cancel (-1), OK (0).
Examples
vector(2) selected
selected.fill 1,3
@uimlist(selected, "Please select an item:", "Item1 Item2 Item3")
These commands display a dialog with a multiple listbox containing the items “Item1”, “Item2”, and “Item3”. The title “Please select an item:” appears above the listbox, and the first and third items are initially selected. If the user additionally selects the second item and presses OK, the vector SELECTED will contain the elements 1,2,3, and the dialog will return the value 0.
@uimlist(selected, "Please select an item:", "Item1 Item2 Item3")
If no items are selected in the dialog, SELECTED will be a one element vector containing the value -1.
Cross-references
Display prompt dialog.
Syntax: @uiprompt(msg[, button, beep])
msg: string
button: string
beep: string
Return: integer
Displays a prompt dialog with OK, Cancel, or Yes and No buttons. You must specify a message string for the prompt dialog, and optionally the type of icon and buttons the dialog should display. You may also instruct the message box to issue a beep when displayed.
The dialog will return an integer representing the button clicked: Cancel (-1), OK (0), Yes (1), or No (2).
button_type can be one of the following keywords:
“O” | Exclamation icon with OK button (default). |
“OC” | Exclamation icon with OK and Cancel buttons. |
“YN” | Question icon with Yes and No buttons. |
“YNC” | Question icon with Yes, No, and Cancel buttons. |
beep_type can be one of the following keywords. The keywords change the type of beep that is omitted, where those beeps are defined by the Windows operating system definitions. If beep_type is omitted, no beep will be issued.
“B” | Base type of beep on button_type |
“AB” | Asterisk beep |
“CB” | Critical stop / error beep |
“QB” | Question beep |
“EB” | Exclamation beep |
“DB” | Default beep |
Examples
@uiprompt("Error: Too many observations")
Displays a dialog with the message “Error: Too many observations” and the OK button.
@uiprompt("Exceeded count. Would you like to continue?", "YNC")
Displays a dialog with the error message “Exceeded count. Would you like to continue?” and the YES, NO, and CANCEL buttons. If the user presses the YES button, the dialog will return the value 1.
Cross-references
Displays a dialog with radio buttons.
Syntax: @uiradio(arg, prompt, items)
arg: scalar, program variable
prompt: string
items: string
Return: integer
Displays a dialog with a listbox and prompt string that will be used to label the listbox.
• arg should be an scalar or program variable as it is used to return results. arg is used to provide initial selections, and will contain the dialog specified values on return.
• prompt specifies the text used to label the listbox.
• items is a space delimited list of items in the listbox.
Both prompt and items may be specified using in-line text.
The dialog shows an OK and Cancel button, and will return an integer representing the button clicked: Cancel (-1), OK (0).
Examples
scalar selection = 2
@uiradio(selection, "Please select an item:", "Item1 Item2 Item3")
These commands display a dialog with three radio buttons, labeled “Item1”, “Item2”, and “Item3”. The title “Please select an item:” appears above the radio buttons, and the second item is initially selected. If the user selects the third item and presses OK, the scalar SELECTION will contain the value 3, and the dialog will return the value 0.
Cross-references
Vector or svector of unique values of object.
Syntax: @uniquevals(o)
o: series, matrix, vector, alpha
Return: vector, svector
Returns a vector or svector containing the list of unique values in the object specified by arg.
• If arg is a series, vector or matrix, @uniquevals will return a vector object containing the unique elements of the series, vector or matrix.
• If arg is an alpha series, @uniquevals will return an svector of the unique values in the alpha.
Examples
vector vals = @uniquevals(x)
returns a vector containing the unique values in x.
vector ivals = @sort(@uniquevals(x))
returns a vector of the unique values of X, sorted from low to high.
Cross-references
Extracts column from an identity matrix.
Syntax: @unitvector(n1, n2)
n1: integer
n2: integer
Return: vector
Creates an n1 element vector with a 1 in the n2-th element, and 0 elsewhere.
Examples
vector v1 = @unitvector(8, 5)
creates an 8 element vector with a 1 in the fifth element and 0 for the other 7 elements.
vector v2 = @unitvector(8, 3)
matrix h = @mnrnd(8, 8)
matrix hselect1 = h * v2
matrix hselect2 = h.@col(3)
create HSELECT1 and HSELECT2 into which we extract column 3 from the matrix H.
Cross-references
Unstack vector into a matrix.
Syntax: @unvec(v, n)
v: vector
n: integer
Return: matrix
Creates an n-row matrix filled with the unstacked elements of the vector v. EViews will report a size mismatch if the number of elements of v is not evenly divisible by n.
Note that @unvec is the inverse of the @vec function.
Examples
vector v1 = @mrnd(12)
creates a 12 element vector of uniform random numbers V1 and unstacks it into a

matrix M1.
matrix m2 = @mnrnd(12, 3)
matrix m3 = @unvec(@vec(m2), 6)
generates a

matrix of random normals M2, then reshapes the matrix into a

matrix M3.
Cross-references
See also
@unvech,
@vec, and
@vech.
Unstack vector into lower triangle of sym.
Syntax: @unvech(v)
v: vector
Return: sym
Creates a sym matrix with lower triangle filled using the unstacked elements of the vector v. The sym will be sized automatically. EViews will report a size mismatch if the number of elements of v does not correspond to a valid sym matrix size (is not a triangular number).
Note that @unvech is the inverse of the @vech function.
Examples
vector v1 = @mnrnd(15)
sym s1 = @unvech(v1)
creates a 15-element vector of normal random numbers V1 and unstacks it into a

sym matrix S1.
Cross-references
See also
@unvec,
@vec, and
@vech.
Uppercase representation of string or upper triangular matrix of a matrix.
String
Syntax: @upper(str)
str: string
Return: string
Returns the uppercase representation of the string str.
Matrix
Syntax: @upper(x[, n])
x: matrix, sym
n (optional) integer
Return: matrix
Returns a matrix whose elements on and above the n-th diagonal match the corresponding elements of the matrix m, but whose elements below the n-th diagonal are zero.
By default, n is has a value of zero indicating the main diagonal. Positive values of n indicate super-diagonals, while negative values of k indicate sub-diagonals.
Examples
String
If we define the string object
string s1 = "I did NOT do it"
the commands
@upper("I did NOT do it")
@upper(s1)
return the string “I DID NOT DO IT”.
If ALPHA1 is an alpha series,
alpha alphalwr = @upper(alpha1)
returns the upper of the strings in ALPHA1 for each observation in the workfile sample.
If SVEC1 is an string vector,
svector sveclen = @upper(svec1)
returns a string vector containing the uppercased elements of SVEC1.
Matrix
The commands
matrix(3,3) m1
m1.fill 1, 2, 3, 4, 5, 6, 7, 8, 9
matrix u1 = @upper(m1)
matrix u2 = @upper(m1, 1)
matrix u3 = @upper(m1, -1)
create a

matrix M1 holding the values
while the matrix U1 contains,
the matrix U2 contains,
and the matrix U3 contains,
If we have the commands,
sym s = @rwish(@identity(5), 5)
matrix s1 = @upper(s)
matrix s2 = @upper(s, 1)
matrix s2 = @upper(s, 1)
then S is a

sym matrix and S1 is a

upper triangular matrix with elements at or above the main diagonal equal to those in S, and elements below the main diagonal equal to zero. S2 is a strictly upper triangular matrix that is equal to S1, but with the main diagonal elements also set to 0.
Cross-references
Convert local time to UTC (Coordinated Universal Time).
Syntax: @utc(localtime[, timezone])
localtime: date number, series, vector
timezone: (optional) string, alpha, svector
Return: date number, series, vector
Returns the Coordinated Universal Time (UTC) value for a point in time input using a local time zone value.
• If timezone is not provided, the current Windows time zone setting is used as the local time zone target.
• If
timezone is provided, the
timezone string can either contain raw time zone information in the format returned by
@tzspec or it can contain search text (such as a city name) found within one of the time zone descriptions returned by the function
@tzlist.
Examples
The commands
scalar dtime = @now
@utc(dtime, "-08:00")
convert local time at an 8 hour shift from UTC into UTC times.
If LOCALTIME is a series of local time values,
series utctime = @utc(localtime, "-05:00")
converts a series containing local time values at a 5 hour shift from UTC into a series containing UTC times, for observations in the workfile sample.
series utctime = @utc(localtime, "Pacific")
converts a series containing local time values in U.S. Pacific Time Zone (including daylight time adjustments) into a series containing UTC, for observations in the workfile sample.
if VLOCALTIME is a vector of time values,
vector vutctime = @utc(vlocaltime, "Stockholm")
converts the vector of local times in Stockholm, into UTC times.
Cross-references
See
“Dates” and
“Event Functions” for related discussion.
See also the related time zone functions
@localt,
@tz,
@tzlist and
@tzspec.