cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
dn610
Level III

JMP Scripting Collapsing Whitespace in All Columns

Is there an easy way to collapse whitespace in all the columns using JMP Scripting? 

1 ACCEPTED SOLUTION

Accepted Solutions
Joseph_Reese
Level IV

Re: JMP Scripting Collapsing Whitespace in All Columns

Hello, just in case you are asking about performing a Collapse Whitespace function on every character column to remove excess whitespaces there is a script below. I am sure there are many ways to do this but I just stole some code from the advanced log after manually recoding a column. Wasn't sure exactly what you were asking for so thought I would provide this just in case.

 

Names Default to Here(1);

dt = Current Data Table();

Cols = dt << Get Column Names( Character, String);

For(
	i = 1, i <= N Items( Cols ), i++,
	
	Eval(
		Eval Expr(
	
			dt << Begin Data Update;
			dt << Recode Column(
			Expr( Column( dt,  Cols[i] ) ),
			{Collapse Whitespace( _rcNow )},
			Update Properties( 1 ),
			Target Column( Column( dt, Expr( Cols[i] ) ) )
			
		)
		
	)

	
);

dt << End Data Update;
	
)

View solution in original post

7 REPLIES 7
ErraticAttack
Level VI

Re: JMP Scripting Collapsing Whitespace in All Columns

Try sending the message <<Optimize Display, as shown in the Scripting Index

ErraticAttach_0-1648586449076.png

 

Jordan
txnelson
Super User

Re: JMP Scripting Collapsing Whitespace in All Columns

If you want to do this interactively,

  1. Select all of the columns you want to change width on
  2. Hold down the Shift and ALT keys
  3. Go to the edge border of one of the columns you have selected, and click and drag the column width to the width you want.  All of the selected columns will expand or contract to your specified width

 

Jim
Joseph_Reese
Level IV

Re: JMP Scripting Collapsing Whitespace in All Columns

Hello, just in case you are asking about performing a Collapse Whitespace function on every character column to remove excess whitespaces there is a script below. I am sure there are many ways to do this but I just stole some code from the advanced log after manually recoding a column. Wasn't sure exactly what you were asking for so thought I would provide this just in case.

 

Names Default to Here(1);

dt = Current Data Table();

Cols = dt << Get Column Names( Character, String);

For(
	i = 1, i <= N Items( Cols ), i++,
	
	Eval(
		Eval Expr(
	
			dt << Begin Data Update;
			dt << Recode Column(
			Expr( Column( dt,  Cols[i] ) ),
			{Collapse Whitespace( _rcNow )},
			Update Properties( 1 ),
			Target Column( Column( dt, Expr( Cols[i] ) ) )
			
		)
		
	)

	
);

dt << End Data Update;
	
)
dn610
Level III

Re: JMP Scripting Collapsing Whitespace in All Columns

This is exactly what I'm looking for, but it didn't work for me. I got the error message below when I tried the script. 

dn610_0-1648645368731.png

 

dn610
Level III

Re: JMP Scripting Collapsing Whitespace in All Columns

I tweaked it, and it now works. Thank you!

Joseph_Reese
Level IV

Re: JMP Scripting Collapsing Whitespace in All Columns

@dn610  You may not be using JMP 16. I have noticed that when using the Recode script, in version 16 that line for Update Properties gets added. If you just delete that line for update properties the code should still work for earlier versions.

dn610
Level III

Re: JMP Scripting Collapsing Whitespace in All Columns

 I'm using JMP 15, and that's exactly what I did to make it work. Thanks again!