cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Have your say in shaping JMP's future by participating in the new JMP Wish List Prioritization Survey
Choose Language Hide Translation Bar

How to get the last data col name?

Hi.

 

I would like to get the col name of the last data written using JSL,

Is there a solution?

 

NetflixDingo567_0-1715921546447.png

 

Thanks.

1 REPLY 1
jthi
Super User

Re: How to get the last data col name?

There is a solution (or many of them). Are all of your columns numeric or can there be character columns?

 

Edit:

Here is one option assuming there can be character columns

Names Default To Here(1);

dt = New Table("Untitled",
	Add Rows(3),
	Compress File When Saved(1),
	New Column("Column 1", Numeric, "Continuous", Format("Best", 12), Set Values([1, ., 1])),
	New Column("Column 2", Numeric, "Continuous", Format("Best", 12), Set Values([., 2, 2])),
	New Column("Column 3", Numeric, "Continuous", Format("Best", 12), Set Values([., ., .])),
	New Column("Column 4", Numeric, "Continuous", Format("Best", 12), Set Values([., ., 3])),
	New Column("Column 5", Character, Nominal, Format("Best", 12), Set Values({"a", "", ""}))
);

newcol = dt << New Column("lastdata", Character, Nominal);
collist = dt << Get Column Names("String");

For Each Row(dt,
	m = Loc(Matrix(!IsMissing(dt[Row(), collist])));
	lastdata = Max(m);
	newcol[Row()] = collist[lastdata];
);

jthi_0-1715922113837.png

 

-Jarmo