Hi,
New to JMP and have searched and read loads of help and going around in circles. I would think what I am doing is easy and straight forward but not getting that feeling from JSL. I have a more complicated data table but for the purpose of trying to get my code to work I have simplified my table. I have a table with 5 columns, 4 of each have "_Yield" in the heading. 13 rows consist of 1's and 0's and what I am trying to do is create a column for each row that shows the first occurrence of a 1 in the yield columns. I need this to be smart as the column names (other than contain _yield) will not always have the same names or be in the same locations. I have figured out how to just look at the yield columns and have converted this to a matrix where I can then find the values I am looking for. I just cant convert these values into the column headers. The test column shows position in matrix, the result column below shows what I should be getting in the Help column. Thanks in advance.

dt = Current Data Table();
lst = dt << Get Column Names(string);
dt << clear column selection;
For( i = 1, i <= N Items(lst), i++,
If( Contains( lst[i], "_Yield" ) > 0,
Column( dt, lst[i] ) << set selected;
selcols = dt << get selected columns;
));
Mat2 = dt << Get as Matrix(selcols);
DesList = list();
for(i = 1 , i <= N Rows(Mat2), i++,
Pos = Min(Loc(Mat2[i,0]));
Insert Into(DesList,Pos);
);
dt << New Column("Test",Numeric,Continuous,<< Set Values(DesList));
cols = dt << Get Column Reference(dt << Get Column Names);
dt << New Column("Result", formula(If( Contains( Eval List( selcols ), 1 ) == 1,
"B_Yield",
If( Contains( Eval List( selcols ), 1 ) == 2,
"C_Yield",
If( Contains( Eval List( selcols ), 1 ) == 3,
"D_Yield",
If( Contains( Eval List( selcols ), 1 ) == 4,
"E_Yield",
"PASS"
))))
));
values1 = Column(dt, selcols[1]) << Get Values;
NewColName = "HELP";
dt << New Column(NewColName, Character);
newColumn = Column(NewColName);
For( j = 1, j <= N Items(values1), j++,
//yield = list box(selcols, << set selected(2,1), Print ("list",yield << get selected, yield << get selected indices));
result = (Deslist[j] >= 1);
if(result >= 1,(newcolumn[j]= selcols),
is missing(result), (newColumn[j]= Parse("PASS")));
);