cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
The Discovery Summit 2025 Call for Content is open! Submit an abstract today to present at our premier analytics conference.
Choose Language Hide Translation Bar
View Original Published Thread

How to set format for a column group (i.e. not individually)?

Neo
Neo
Level VI

I have a column group for which I want to change the format. I know how to do this for a given column as below

Names Default To Here (1);
dt = Open ("myTable.jmp"); 
//Show( dt:myCol << get format );
dt:myCol<< Format( "Fixed Dec", 10, 2 );
//Show( dt:myCol<< get format );

How to do this for column group in JSL?

(I guess I need a JSL variant of this https://community.jmp.com/t5/Discussions/how-to-multiple-column-format-at-once/td-p/238726 )

When it's too good to be true, it's neither
1 ACCEPTED SOLUTION

Accepted Solutions
Neo
Neo
Level VI

Re: How to set format for a column group (i.e. not individually)?

The following does the job for me. Thanks.

 

Names Default To Here( 1 ); dt = Open ("myDataTable.jmp"); /*load data table*/ListofNumericCols = dt << get column names(numeric, Continuous); //get list of columns to group
NumericCols = dt << Group Columns ("NumericCols",ListofNumericCols);  // group columns
dt<< Select Columns (dt<<Get Column Group(NumericCols)); // select grouped columns
selecedColNames = dt << Get Selected Columns; // get column names in a list
\\ set desired format for the column groupLocal( {old dt = Current Data Table()},
	Current Data Table( Data Table( "myDataTable" ) );
	For Each( {col, index},
		selecedColNames,
		col << Format( "Fixed Dec", 12, 2 )
	);
	Current Data Table( old dt );
);

 

When it's too good to be true, it's neither

View solution in original post

4 REPLIES 4
Victor_G
Super User


Re: How to set format for a column group (i.e. not individually)?

Hello @Neo,

 

When selecting multiple columns, you can right-click on them and select "Standardize Attributes" (Standardize Attributes and Properties Across Columns (jmp.com)) :

Victor_G_0-1684238550629.png

Looking at the script log, you can then extract the code for this attributes standardization. Example here is :

// Standardize column attributes
Local( {old dt = Current Data Table()},
	Current Data Table( Data Table( "Test" ) );
	For Each( {col, index}, {:Column 1, :Column 2, :Column 3},
		col << Data Type( Numeric, Format( "Fixed Dec", 12, 2 ) ) << Set Modeling Type( "Continuous" )
	);
	Current Data Table( old dt );
);

Hope this answer will help you,

Victor GUILLER

"It is not unusual for a well-designed experiment to analyze itself" (Box, Hunter and Hunter)
Neo
Neo
Level VI


Re: How to set format for a column group (i.e. not individually)?

@Victor_G 

Thanks. I am trying to avoid 

{:Column 1, :Column 2, :Column 3}

as these are expected to change on a case by case basis. I can select the relevant (numeric) columns as 

ListofNumericCols = dt << get column names(numeric, Continuous);
NumericCols = dt << Group Columns ("NumericCols",ListofNumericCols); 
dt<< Select Columns (dt<<Get Column Group(NumericCols));

and then I want to change the format of the group "NumericCols" at once. How to/Can we do this in JSL?

When it's too good to be true, it's neither
Neo
Neo
Level VI

Re: How to set format for a column group (i.e. not individually)?

The following does the job for me. Thanks.

 

Names Default To Here( 1 ); dt = Open ("myDataTable.jmp"); /*load data table*/ListofNumericCols = dt << get column names(numeric, Continuous); //get list of columns to group
NumericCols = dt << Group Columns ("NumericCols",ListofNumericCols);  // group columns
dt<< Select Columns (dt<<Get Column Group(NumericCols)); // select grouped columns
selecedColNames = dt << Get Selected Columns; // get column names in a list
\\ set desired format for the column groupLocal( {old dt = Current Data Table()},
	Current Data Table( Data Table( "myDataTable" ) );
	For Each( {col, index},
		selecedColNames,
		col << Format( "Fixed Dec", 12, 2 )
	);
	Current Data Table( old dt );
);

 

When it's too good to be true, it's neither


Re: How to set format for a column group (i.e. not individually)?

You do not need to first select columns in a group and then get their references.

Names Default To Here( 1 );

// example
dt = Open( "$SAMPLE_DATA/Cities.jmp" );

// create column groups
dt << group columns( "xy", {:X, :y} );
dt << group columns( "pollutants", :Ozone :: :Lead );

// get col references to each member in group
col = dt << get column group( "xy" );

// iterate over list and make change to attribute or proptery
For( c = 1, c <= N Items( col ), c++,
	col[c] << Format( "Fixed Dec", 6, 2 );
);