14.03.2014 Views

Download Jmp User Guide

Download Jmp User Guide

Download Jmp User Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

324 Formula Editor Chapter 9<br />

Examples and Tutorials<br />

Figure 9.40 Local Variables in a Formula<br />

Note: You can also create local variables using the button on the on-screen keypad. Clicking this<br />

button creates a local variable with a default name in an expression and places a semicolon after it. The<br />

default name is t1, and additional local variables are named t2, t3, and so forth. You can change these<br />

default names by double-clicking and editing the name. However, you must be careful to rename each<br />

instance of the variable to avoid errors.<br />

Using the Munger Function<br />

The following examples show uses of the Munger function. In these examples, assume that there is a<br />

character column of names with “Veronica Layman” as one of its values. To simplify the examples, the<br />

literal name “Veronica Layman” is the search string instead of a column name.<br />

See “Adding Character Arguments and Returning Character Strings,” p. 300, for instructions on how<br />

to incorporate Character functions, such as Munger, into a formula.<br />

Inserting Characters<br />

This Munger example finds the blank between the first and last name, and inserts the middle initial<br />

“J.” The formula Munger("Veronica Layman", 1, " ", " J. ") inserts the middle initial J., and evaluates as<br />

Veronica J. Layman.<br />

Double quotes are required by the Munger function for literal strings, including strings that consist of<br />

a blank or when leading or trailing blanks are part of a string.<br />

Deleting Characters<br />

To delete one or more characters from a string<br />

1 Designate the characters to delete as the Find string in the Munger function.<br />

2 Enter an empty Replace string: two quotation marks with nothing between them.<br />

For example, the function, Munger("Veronica Layman", 1, "onic", "") removes the “onic” from<br />

Veronica and evaluates as Vera Layman.<br />

Note: A Replace field with a null (no value) string enclosed in quotation marks is different from a<br />

Replace field with no value. If you delete the Replace string altogether, Munger shows the argument<br />

name (“Replace”) in the formula editor window and behaves as if that optional argument doesn't exist.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!