cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
Sburel
Level IV

Create a loop to add column properties to columns that contain a specific header

Hello,

 

Being still new with JSL, I'm still struggling with the implementation of certain concepts namely looping.

 

Any way, I'm trying to create a script which would add to any column in a table in which the header contains "Norm" a number of specific column properties.

dt=current data table();
a = "Norm";
col = dt << get column names( string );
nc = N Items( col );
For( i = 1, i <= nc, i++,
If( Contains( col[i], a ),
col[i]<<Add Column Properties(
	Set Property( "Axis", {Add Ref Line( 200, "Dotted", "Red", "", 2 )} )
)
)
);

Unfortunately, I'm clearly missing something fundamental and the script is not going anywhere.Some guidance would be greatly appreciated.

 

Thanks

 

Sebastien

 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Create a loop to add column properties to columns that contain a specific header

See if this is what you want

Names Default To Here( 1 );
dt = Current Data Table();
a = "Norm";
col = dt << get column names( string );
nc = N Items( col );
For( i = 1, i <= nc, i++,
	If( Contains( col[i], a ),show(col[i]);
		column(col[i]) << Set Property( "Axis", Add Ref Line( 200, "Dotted", "Red", "", 2 ) )
	)
);
Jim

View solution in original post

2 REPLIES 2
txnelson
Super User

Re: Create a loop to add column properties to columns that contain a specific header

See if this is what you want

Names Default To Here( 1 );
dt = Current Data Table();
a = "Norm";
col = dt << get column names( string );
nc = N Items( col );
For( i = 1, i <= nc, i++,
	If( Contains( col[i], a ),show(col[i]);
		column(col[i]) << Set Property( "Axis", Add Ref Line( 200, "Dotted", "Red", "", 2 ) )
	)
);
Jim
Sburel
Level IV

Re: Create a loop to add column properties to columns that contain a specific header

Worked like a charm.

Thanks a lot for the very rapid suggestion.

Much appreciated