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
Leyahans
Level I

Rename subgroup column names from summary table

Hi all, 

I need help with my script. I have a script that creates a summary table from raw data table as below;

Data Table( "DVIRCR_SumTable" ) << Summary(
	Group( :prodgroup3, :subapp ),
	Max( :rcr% ),
	Subgroup( :date_ ),
	Freq( "None" ),
	Weight( "None" ),
	statistics column name format( "column" ),
	Link to original data table( 0 )
);
 
//rename N Rows column to Lot Count
:Name( "N Rows" ) << Set Name( "Lot Count" );
******

 

Now i need to rename the subgroup column automatically. The date will change everyday.

i want to change from current format -- rcr%(:date_) to format -- :date_

Ultimately i don't want any rcr% word in front of the date. 

Leyahans_0-1701248037186.png

 

1 REPLY 1
txnelson
Super User

Re: Rename subgroup column names from summary table

Here is a modification to your script.  The first modification is gives a name to the summary table

Output Table( "My Summary" )

The second modification loops through all columns in the new table and changes any column who's name starts with "rcr%," and changes the name.

// Create a list of all of the column
colNames = Data Table( "My Summary" ) << get column names( string );

// Loop through all of the names, and when "rcr%," is found in the 
// start of the column name, change the name to the column name 
// starting from the 7th character in the name
For Each( {col}, colNames,
	If( Contains( col, "rcr%," ) == 1,
		Column( col ) << set name( Substr( col, 7 ) )
	)
);

Here is the complete script

Names Default to Here( 1 );
Data Table( "DVIRCR_SumTable" ) << Summary(
	Group( :prodgroup3, :subapp ),
	Max( :rcr% ),
	Subgroup( :date_ ),
	Freq( "None" ),
	Weight( "None" ),
	statistics column name format( "column" ),
	Link to original data table( 0 ),
	Output Table( "My Summary" )
);
 
//rename N Rows column to Lot Count
:Name( "N Rows" ) << Set Name( "Lot Count" );

// Create a list of all of the column
colNames = Data Table( "My Summary" ) << get column names( string );

// Loop through all of the names, and when "rcr%," is found in the 
// start of the column name, change the name to the column name 
// starting from the 7th character in the name
For Each( {col}, colNames,
	If( Contains( col, "rcr%," ) == 1,
		Column( col ) << set name( Substr( col, 7 ) )
	)
);

Also, please enter your JSL into discussions using the txnelson_1-1701262046257.png icon which displays the JSL in a format easier for the Community Members to read and understand the issue.

 

Jim