Choose Language Hide Translation Bar
Highlighted
Level III

## Combining Indicator Columns

Hello all!

I have created what I believe are referred to as indicator columns. In my study I have two red herring questions to see if respondents are paying attention, not my idea, and I am trying to create a single variable containing...

1. Those who answered both correctly
2. Those who answered ONE wrong
3. Those who answered BOTH wrong

So we have a mutually exclusive set of groups. When I filtered I flagged TRUE with "1" and FALSE with nothing. I did this with all three groups which has left me with 3 columns that mirror the below excluding the last column...

BothCorrectOneWrongTwoWrongWhat I want
.2.2
1..1
..33

What I am trying to do is combine the first 3 columns into the last at which point I would go in and label what 1, 2 and 3 are.

I tried a formula...

`If(:BothCorrect == 1, 1, If(:OneWrong == 2, 2, If(:TwoWrong == 3, 3, "NA")))`

That did not work, likely due to syntax.

Could anyone provide some guidance on this, please, with or without the use of a formula?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Staff

## Re: Combining Indicator Columns

If you have numeric columns and you're just looking for the first non missing value (or if you can assume that only one of the three columns will be non missing), this column formula might do want you need:

If( !Is Missing( :BothCorrect ),

:BothCorrect,

If( !Is Missing( :OneWrong ),

:OneWrong,

If( !Is Missing( :TwoWrong ),

:TwoWrong,

.

)

)

)

Michael Crotty
Sr Statistical Writer
JMP Development
4 REPLIES 4
Highlighted
Staff

## Re: Combining Indicator Columns

If you have numeric columns and you're just looking for the first non missing value (or if you can assume that only one of the three columns will be non missing), this column formula might do want you need:

If( !Is Missing( :BothCorrect ),

:BothCorrect,

If( !Is Missing( :OneWrong ),

:OneWrong,

If( !Is Missing( :TwoWrong ),

:TwoWrong,

.

)

)

)

Michael Crotty
Sr Statistical Writer
JMP Development
Highlighted
Level III

## Re: Combining Indicator Columns

Michael,

Thank you, that did work, but I had to go back into the formula and include the "!" before the "Is missing". What is the "!" doing exactly?

Highlighted
Staff

## Re: Combining Indicator Columns

The "!" is a shorthand notation in JSL for the Not() function. It negates its argument. So !IsMissing(x) returns 1 if x is not missing and zero if x is missing.

Michael Crotty
Sr Statistical Writer
JMP Development
Highlighted
Level III

Thank you!