cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
New to using JMP? Hit the ground running with the Early User Edition of Discovery Summit. Register now, free of charge.
Register for our Discovery Summit 2024 conference, Oct. 21-24, where you’ll learn, connect, and be inspired.
Choose Language Hide Translation Bar
mengzy1974
Level I

How do I delete columns in a data table with their names containing "UL" or "LL" or "UCL" or "LCL" or "USL" or "LSL" and the column containing only "." (NOT empty)

I have a large dataset on hand and want to delete all columns whose name contain "UL" or "LL" or "UCL" or "LCL" or "USL" or "LSL" and the whole column only contains "." but not empty except the column name. (images are shown below) I did not know how to do this after searching Google and read the JMP manual. Thanks for help on this.

 

mengzy1974_0-1615506089720.png

mengzy1974_1-1615506171257.png

 

 

 

1 REPLY 1
jthi
Super User

Re: How do I delete columns in a data table with their names containing "UL" or "LL" or "UCL" or "LCL" or "USL" or "LSL" and the column containing only "." (NOT empty)

Something like this might do it:

 

Names Default To Here(1);

dt = New Table("Untitled 390",
	Add Rows(9),
	Compress File When Saved(1),
	New Column("a",
		Numeric,
		"Continuous",
		Format("Best", 12),
		Set Values([., ., ., ., ., ., ., ., .])
	),
	New Column("a+LCL",
		Numeric,
		"Continuous",
		Format("Best", 12),
		Set Values([1, ., ., ., ., ., ., ., .])
	),
	New Column("b+LCL",
		Numeric,
		"Continuous",
		Format("Best", 12),
		Set Values([., ., ., ., ., ., ., ., .])
	)
);

wait(1);

colNames = dt << Get Column Names("String");
colContainsList = {"UL", "LL", "UCL", "LCL", "USL", "LSL"};

For(i = 1, i <= N Items(colNames), i++,
	For(k = 1, k <= N Items(colContainsList), k++,
		If(Contains(colNames[i], colContainsList[k]),
			Summarize(dt, uniqValues = By(colNames[i]));
			If(N Items(uniqValues) == 1 & uniqValues[1] == ".",
				dt << Delete Columns(colNames[i]);
			);
			break();
		);
	);
);

Are you sure you want to check if column name contains any of those strings or if the column name ends in them?

-Jarmo