cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
Emily_Day
Level I

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".

Maybe I've gone about this all wrong and there is a better way to accomplish this task?  Any suggestions?

 

Data

Answer 1Answer 2Answer 3
1,2,3,6,11111
2,5,6,11010
3,11,12,13001
1 ACCEPTED SOLUTION

Accepted Solutions
Byron_JMP
Staff

Re: Question Regarding "contains()" formula

This might help

 

select your "Data" column

Cols>Utilities>Text into columns

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

 

 

JMP Systems Engineer, Health and Life Sciences (Pharma)

View solution in original post

3 REPLIES 3
Byron_JMP
Staff

Re: Question Regarding "contains()" formula

This might help

 

select your "Data" column

Cols>Utilities>Text into columns

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

 

 

JMP Systems Engineer, Health and Life Sciences (Pharma)
Emily_Day
Level I

Re: Question Regarding "contains()" formula

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

Much appreciated!

G_M
G_M
Level III

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",
	Add Rows( 3 ),
	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(
	"Answer",
	Numeric,
	Nominal,
	Formula(
		"Insert your Logic Here"
	)
);

dtWide = dtStacked << Split(
	Split By( :Label ),
	Split( :Answer ),
	Group( :Data ),
	Remaining Columns( Drop All ),
	Sort by Column Property,
	Ouput Table Name("WideData")
);