Choose Language Hide Translation Bar
Highlighted

## Question Regarding "contains()" formula

I have a set of CATA data where the nominal data looks like column "Data" below.  I'm attempting to create an additional column for each selection (like "Answer 1, Answer 2, etc. below) where "0" = not found in the list and "1"= found.

Here is my formula:                       Contains( :Name( "Data" ), "1" ) > 0

However, it is picking up the number 1 from an 11 and is returning a "1" response for Answer 1 when it should be "0".

 Data Answer 1 Answer 2 Answer 3 1,2,3,6,11 1 1 1 2,5,6,11 0 1 0 3,11,12,13 0 0 1
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

## Re: Question Regarding "contains()" formula

This might help

Cols>Utilities>Text into columns

then use "," as the delimiter and check the, Make Indicator columns.

JMP Systems Engineer, Pharm and BioPharm Sciences
3 REPLIES 3
Highlighted

## Re: Question Regarding "contains()" formula

This might help

Cols>Utilities>Text into columns

then use "," as the delimiter and check the, Make Indicator columns.

JMP Systems Engineer, Pharm and BioPharm Sciences
Highlighted

## Re: Question Regarding "contains()" formula

Beautiful!  That is exactly what I needed and way easier than my round-about method.

Much appreciated!

Highlighted

## Re: Question Regarding "contains()" formula

@Emily_DayI am not sure I understand your logic completely, but perhaps the following will help.

``````Names Default to Here(1);

dt = New Table( "Sample",
New Column( "Data",
Character,
"Nominal",
Set Values( {"1,2,3,6,11", "2,5,6,11", "3,11,12,13"} )
)
);

dt << Text To Columns(
delimiter( "," ),
columns( :Data )
);

dtStacked = dt << Stack(
columns( :Data 1, :Data 2, :Data 3, :Data 4, :Data 5 ),
Source Label Column( "Label" ),
Stacked Data Column( "Response" ),
Output Table Name("StackedData")
);
dtStacked:Response<<Data Type("Numeric");

dtStacked << New Column(
Numeric,
Nominal,
Formula(
)
);

dtWide = dtStacked << Split(
Split By( :Label ),