Combining Indicator Columns<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />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...
- Those who answered both correctly
- Those who answered ONE wrong
- 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...
| BothCorrect | OneWrong | TwoWrong | What I want |
|---|
| . | 2 | . | 2 |
| 1 | . | . | 1 |
| . | . | 3 | 3 |
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?
Re: Combining Indicator ColumnsThank you!
Re: Combining Indicator ColumnsThe "!" 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.
Re: Combining Indicator ColumnsMichael,
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?
Re: Combining Indicator ColumnsIf 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,
.
)
)
)