Our World Statistics Day conversations have been a great reminder of how much statistics can inform our lives. Do you have an example of how statistics has made a difference in your life? Share your story with the Community!
Choose Language Hide Translation Bar
Highlighted
Level III

When i use below script, the row 4 not change to "yes", but other rows change. Would you help check again?   My purpose is to realize that when :Height > "60" &(and)  isMissing( :Weight ) == 0, both realize, then the height value change to "Yes", other values no change on height.

``````dt = Open( "\$SAMPLE_DATA/Big Class.jmp" );
// Set the value of JACLYN's weight to missing
// to allow for the test case, where the
// :Height is greater than 60, but the :Weight
// is missing
dt:Weight[4] = .;
// Since the column :height is numeric and a
// character value of "Yes" is to be placed in
// that column, the column needs to be changed
// to Data Type of Character
dt:Height << data type(character);
// Now a For Each Row() with a two level
// comparison can be used to change the
// described value
For Each Row(
If( :Height > "60" & isMissing( :Weight ) == 0,
:Height = "Yes"
)
);``````

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Staff (Retired)

Re: questions about logic operation selection

isMissing(x) returns 1 if x is missing, 0 if x is not missing. You can also just use

isMissing(x) without comparing it to 1 or 0; the returned value is the same, but it might be easier to read:

``````If( :Height > "60" & isMissing( :Weight ) , ... )
or
If( :Height > "60" & ! isMissing( :Weight ) , ... )``````

notice the ! which means not .

Craige
2 REPLIES 2
Highlighted
Staff (Retired)

Re: questions about logic operation selection

isMissing(x) returns 1 if x is missing, 0 if x is not missing. You can also just use

isMissing(x) without comparing it to 1 or 0; the returned value is the same, but it might be easier to read:

``````If( :Height > "60" & isMissing( :Weight ) , ... )
or
If( :Height > "60" & ! isMissing( :Weight ) , ... )``````

notice the ! which means not .

Craige
Highlighted
Level III

Re: questions about logic operation selection

thank you it works
Article Labels

There are no labels assigned to this post.