Subscribe Bookmark RSS Feed

Create a new column from others

ckaylor

Community Member

Joined:

Aug 12, 2016

I have a set of continuous measures (x1, x2, x3, x4) that are all measured on the same scale. I'd like to create a new nominal variable that identifies for each respondent which of the continuous measures is the maximum (whether x1, x2, etc).

3 REPLIES
ms

Super User

Joined:

Jun 23, 2011

One way is to use a column formula including Loc Max() function to identify the column with maximum value.

Example:

// Make example table

dt = New Table("test", add rows(25), <<add multiple columns("x", 4, Numeric));

For(i = 1, i <= N Col(dt), i++,

    Column(i) << Set Formula(Random Integer(10))

);

// Identify the column with highest value for each row

dt << New Column("max x", Character, Formula("x" || Char(Loc Max(Matrix({x1, x2, x3, x4})))));

Jeff_Perkinson

Community Manager

Joined:

Jun 23, 2011

The If Max()function can take care of this for you in one call.

12424_JMPScreenSnapz029.png

-Jeff
Jeff_Perkinson

Community Manager

Joined:

Jun 23, 2011

BTW: If you're not sure how to get to the Formula Editor to create a formula like this, choose Cols->New Column... ​and then choose Formula from the Column Properties drop down menu.

12425_JMPScreenSnapz030.png

-Jeff