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
- :
- 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
(1182 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

10 REPLIES

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

Apr 14, 2017 8:07 AM
(1174 views)

```
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
(1152 views)

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

Apr 14, 2017 12:22 PM
(1149 views)

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
(1144 views)

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

Apr 14, 2017 1:23 PM
(1139 views)

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
(1136 views)

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

Apr 14, 2017 4:10 PM
(1123 views)

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

Apr 17, 2017 8:51 AM
(1063 views)

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

Apr 15, 2017 7:41 AM
(1103 views)

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")));