We’re asking you to select a content label when starting a new topic in the Discussions area. Read more to find out why.
Choose Language Hide Translation Bar
Highlighted
Theresa
Level III

questions about logic operation selection

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

 

 

Theresa_0-1584920072733.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Craige_Hales
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

View solution in original post

2 REPLIES 2
Highlighted
Craige_Hales
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

View solution in original post

Highlighted
Theresa
Level III

Re: questions about logic operation selection

thank you it works