14.03.2014 Views

Using JMP - SAS

Using JMP - SAS

Using JMP - SAS

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.

Chapter 7 Formula Editor 225<br />

Examples and Tutorials<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 name<br />

(“Replace”) in the Formula Editor window and behaves as if that optional argument does not exist. The<br />

resulting data type can also change from character to numeric, depending on the value of the Find/Length<br />

argument.<br />

Find the Position (Index) of a Value<br />

When the Find/Length field contains characters, Munger behaves like an index function and returns the<br />

numeric position of the first instance of the search string if it exists. For example, Munger("Veronica<br />

Layman", 1, " ") searches for a single blank and finds it in position nine. If the search string is not found,<br />

Munger returns a zero. This use of Munger produces the same result as the Contains function, as shown in<br />

“Character Functions” on page 402 in the “Formula Functions Reference” appendix.<br />

Find a Substring<br />

Munger can extract substrings. For example, to extract only the first name, Munger("Veronica Layman", 1,<br />

8,) starts at position one and reads through position eight. The remaining characters are ignored because the<br />

replace argument is not defined. This yields “Veronica” and produces the same result as the Substring, as<br />

shown in “Character Functions” on page 402 in the “Formula Functions Reference” appendix.<br />

An alternative way to find a substring is with a start value, any negative find value, and a no replace<br />

argument. Munger("Veronica Layman", 9, –1,) returns “Layman”.<br />

Use the Match Conditional Function<br />

This example walks you through using the Match conditional function.<br />

Suppose that you want a Match conditional for the nominal variable Type from the Hot Dogs.jmp sample<br />

data table.<br />

1. In the Formula Editor, select Type from the Table Columns list.<br />

2. Select Conditional from the Functions list.<br />

3. Select Match.<br />

4. Select Add Arguments from Data.<br />

The values are automatically filled in. See Figure 7.12.<br />

Note: Rather than complete step 2 through step 4, hold down the SHIFT key, select Conditional from the<br />

Functions list, and then select Match.

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

Saved successfully!

Ooh no, something went wrong!