cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Don’t miss your chance to experience Discovery Summit Europe at our best available rate! Early bird registration through 31 Oct.
  • Image to Table JMP extension imports single or batch images as data tables. Useful to extract curves from pictures or convert image data to curve data to use in analyses like Functional Data Explorer. Download and install the extension.

Discussions

Solve problems, and share tips and tricks with other JMP users.
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

Recommended Articles