turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- JMP User Community
- :
- Discussions
- :
- Discussions
- :
- IS NUMBER IS MISSING etc.

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Apr 14, 2017 6:46 AM
(3126 views)

I have the following snippet of JSL that checks the My_Graphs list to determine whether the ith row is a number or not and do one of two things (col 6 consists of numbers and "."). The first part of the IF works - it sets the chart min at 1.2 the LCL and draws the plot. However, if the LCL is "." it does not set the LCL to 0. Immediately below is the the first 6 rows of col 6.

.

0.25

-2

-0.018

.

0.25

if**(**Is Number**(**num**(**My_Graphs **[****6][**i**]))**,

**(**Plot << **dispatch(**

**{**"Variability Chart for..."**}**,

"2",

ScaleBox,

**{**Min**(**num**(**My_Graphs **[****6][**i**])** * **1.2** **)**,

Add Ref Line**(** num**(**My_Graphs **[****6][**i**])**, Dotted, "Red", "LCL = " || My_Graphs **[****6][**i**]** , **2** **)**,

Show Major Grid**(** **1** **)})**

**)**,

**(**Plot << **dispatch(**

**{**"Variability Chart for..."**}**,

"2", ScaleBox, **{**Min**(0)})**

**)**

**)**;//end if

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Kev - let's have a chat about this in work...But I think I see your problem.

JMP treats a missing number as a number. So when you execute the code below it returns "It's a number" for every element of num_list.

num_list = {.,0.25,-2,-0.018,.,0.25};

for(i=1,i<=nitems(num_list),i++,if(IsNumber(num_list[i]),Print("It's a number"), Print ("It's not a number")));

What I suggest you do instead is change your if condition to handle the missing one first, followed by is number and then some catch expression.

num_list = {.,0.25,-2,-0.018,.,0.25};

for(i=1,i<=nitems(num_list),i++,if(IsMissing(num_list[i]),Print("It's Missing"), IsNumber(num_list[i]), Print ("It's a number"),Print("I don't know what to do now")));

10 REPLIES

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

```
x=.;
show( x, isNumber(1), isNumber(0), isNumber(.), isMissing(0), isMissing(.), if( x==x, "yes", "no") )
x = .;
Is Number(1) = 1;
Is Number(0) = 1;
Is Number(.) = 1;
Is Missing(0) = 0;
Is Missing(.) = 1;
If(x == x, "yes", "no") = .;
```

Missing values are numbers and require the isMissing function to test for them. A comparison against a missing value returns missing, not 0 or 1, even if both values are missing.

Craige

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Apr 14, 2017 12:06 PM
(3096 views)
| Posted in reply to message from Craige_Hales 04/14/2017 11:07 AM

This should work then but it doesn't?

if**(**!Is Missing**(**My_Graphs **[****6][**i**])**,

**(**Plot << **dispatch(**

**{**"Variability Chart..."**}**,

"2",

ScaleBox,

**{**Min**(**num**(**My_Graphs **[****6][**i**])** * **1.2** **)**,

Add Ref Line**(** num**(**My_Graphs **[****6][**i**])**, Dotted, "Red", "LCL = " || My_Graphs **[****6][**i**]** , **2** **)**,

Show Major Grid**(** **1** **)})**

**)**,

**(**Plot << **dispatch(**

**{**"Variability Chart..."**}**,

"2", ScaleBox, **{**Min**(0)})**

**)**

**)**;//end if

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

When you say it doesn't work, what exactly do you mean? Are you getting an error? Is the graph updated incorrectly? Not at all?

Can you add a

`Show (My_Graphs [6][i]);`

just before your conditional to see what the value is?

-Jeff

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Apr 14, 2017 1:13 PM
(3088 views)
| Posted in reply to message from Jeff_Perkinson 04/14/2017 03:22 PM

It seems that it doesn't evaluate the false condition for !Is Missing but there's no error.

It updates the min and adds the chart line when there is a value but doesn't set min to 0 for false condition of if.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

We know that the Is Missing() function works. For example:

```
For( i = 1, i <= N Items( x ), i++,
Print( "starting iteration " || Char( i ) );
If( !Is Missing( x[i] ),
Show( x[i] ),
Print( "x is missing" );
Show( x[i] );
);
);
```

/*:
"starting iteration 1"
x[i] = 1;
"starting iteration 2"
"x is missing"
x[i] = .;

So it must be something with the data/values that you're passing to it. That's why the Show() that I suggested above will help.

Maybe you should put a debugging "Show()" in the else clause of the If() as well to show whether it got in there or not.

-Jeff

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Apr 14, 2017 1:42 PM
(3080 views)
| Posted in reply to message from Jeff_Perkinson 04/14/2017 04:23 PM

I'm passing it values from a list created with Summarize which are quoted values?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

When I run the following code I get:

For**(** i = **1**, i <= number, i++,

show**(**My_Graphs**[****6][**i**])**;

**)**;

My_Graphs[6][i] = ".";

My_Graphs[6][i] = "0.25";

My_Graphs[6][i] = "-2";

My_Graphs[6][i] = "-0.018";

My_Graphs[6][i] = ".";

When I run the followng code I get:

For**(** i = **1**, i <= number, i++,

show**(**Is Missing**(**My_Graphs**[****6][**i**]))**;

**)**;

Is Missing(My_Graphs[6][i]) = 0;

Is Missing(My_Graphs[6][i]) = 0;

Is Missing(My_Graphs[6][i]) = 0;

Is Missing(My_Graphs[6][i]) = 0;

Is Missing(My_Graphs[6][i]) = 0;

When I run the following code I get:

For**(** i = **1**, i <= number, i++,

show**(**Is Missing**(**num**(**My_Graphs**[****6][**i**])))**;

**)**;

Is Missing(Num(My_Graphs[6][i])) = 1;

Is Missing(Num(My_Graphs[6][i])) = 0;

Is Missing(Num(My_Graphs[6][i])) = 0;

Is Missing(Num(My_Graphs[6][i])) = 0;

Is Missing(Num(My_Graphs[6][i])) = 1;

It looks like have to covert the list strings to num for the Is Missing function.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

@karmstro wrote:

When I run the following code I get:

For

(i =1, i <= number, i++,show

(My_Graphs[6][i]);

);

My_Graphs[6][i] = ".";

My_Graphs[6][i] = "0.25";

My_Graphs[6][i] = "-2";

My_Graphs[6][i] = "-0.018";

My_Graphs[6][i] = ".";

The quote marks indicate that your values are character strings. As such you'll need to convert them to numbers using the Num() function in order to use the Is Missing() function.

So it should be:

```
if(Is Missing(num(My_Graphs [6][i])),
(Plot << dispatch(
{"Variability Chart for..."},
"2",
ScaleBox,
{Min(num(My_Graphs [6][i]) * 1.2 ),
Add Ref Line( num(My_Graphs [6][i]), Dotted, "Red", "LCL = " || My_Graphs [6][i] , 2 ),
Show Major Grid( 1 )})
),
(Plot << dispatch(
{"Variability Chart for..."},
"2", ScaleBox, {Min(0)})
)
);//end if
```

Which is really close to what you had originally.

Alternatively, you could compare against the text string "." like this:

```
if(My_Graphs [6][i] == ".",
(Plot << dispatch(
{"Variability Chart for..."},
"2",
ScaleBox,
{Min(num(My_Graphs [6][i]) * 1.2 ),
Add Ref Line( num(My_Graphs [6][i]), Dotted, "Red", "LCL = " || My_Graphs [6][i] , 2 ),
Show Major Grid( 1 )})
),
(Plot << dispatch(
{"Variability Chart for..."},
"2", ScaleBox, {Min(0)})
)
);//end if
```

-Jeff

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Kev - let's have a chat about this in work...But I think I see your problem.

JMP treats a missing number as a number. So when you execute the code below it returns "It's a number" for every element of num_list.

num_list = {.,0.25,-2,-0.018,.,0.25};

for(i=1,i<=nitems(num_list),i++,if(IsNumber(num_list[i]),Print("It's a number"), Print ("It's not a number")));

What I suggest you do instead is change your if condition to handle the missing one first, followed by is number and then some catch expression.

num_list = {.,0.25,-2,-0.018,.,0.25};

for(i=1,i<=nitems(num_list),i++,if(IsMissing(num_list[i]),Print("It's Missing"), IsNumber(num_list[i]), Print ("It's a number"),Print("I don't know what to do now")));