Choose Language Hide Translation Bar
Highlighted
yanee
Level III

How to delete columns that show same value

I wants to delete columns that all rows show the same value. So, I start with creating a list of those columns (range == 0). When I run the script, things work ok until I delete columns.  JMP show scriptable but it doesn't delete.

names default to here (1);
dt = current data table ();


for (i= n col (dt), i >= 1, i--,
	if( (col N missing (column (i)) / N Rows() ) > 0.8,
	dt << delete columns (i)
	)
	
);

ColList1 = dt << get column names(continuous);

dt << summary(
	range(eval(ColList1)),
	output table("range")
);

Empty = {};
ColList = data table("range") << get column names(continuous);

for(i=1,i<=n items(ColList),i++,
  col = column(ColList[i]);	
  if(col[1] ==0, insert into(Empty,ColList[i]))
 
);

dt << delete columns(Empty);
1 REPLY 1
Highlighted
txnelson
Super User

Re: How to delete columns that show same value

There is an issue with using a subscript on your "col" variable.  

col = column(ColList[i]);

This sets the variable "col" as a scaler.

if(col[1] ==0, insert into(Empty,ColList[i]))

tries to reference it as a list col[1].  If you change to:

if(col ==0, insert into(Empty,ColList[i]))

it should fix the issue

 

 

 

Jim
Article Labels