cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Instantly extract effect sizes, F-ratios, and FDR-adjusted p-values from your models with the Calculate Effects Sizes extension, available now in the JMP Marketplace!
  • New to JMP? Join us Sept. 23-24 for the Early User Edition of Discovery Summit, tailor-made for new users. Register now for free!
  • See how to use the JMP Marketplace – Free tools to expand JMP capabilities. Register. July 10, 2 pm US Eastern Time.

Discussions

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

Recommended Articles