- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
How to set format for a column group (i.e. not individually)?
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 )
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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 );
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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)) :
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,
"It is not unusual for a well-designed experiment to analyze itself" (Box, Hunter and Hunter)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How to set format for a column group (i.e. not individually)?
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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 );
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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 );
);