BookmarkSubscribe
Choose Language Hide Translation Bar

Create a new column from others

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 3

Re: Create a new column from others

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

Re: Create a new column from others

The If Max()function can take care of this for you in one call. -Jeff  Jeff_Perkinson Community Manager

Re: Create a new column from others

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