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
aliegner1
Level IV

Script to loop thru and group columns by name, dynamically

So I'm trying to figure this out and its just not quite working.

 

I've got a table with a key-value pair that I've SPLIT from Tall to Wide. I end up with about 10k columns that all have a regular naming structure, like 
"15.02.0 param1", "15.02 param2", "15.02 param3"...."15.03 param1", "15.03 param2", "15.03 param3",...

 

How can I look through all these columns and group them dynamically by the starting term? ie. all 15.02% columns in a group, all 15.03% cols, all 15.04%, ... all 17.06%....and name the group based on the groupby number?

 

My script just groups everything into a single group. ug.

 

//**split Aggregate Data from TALL to WIDE, grouping WIDE columns by StepID
dt = current data table();
Summarize( dt, RecipeStepIndex = by( :RecipeStepId) );//get list of unique RecipeStepID's

//split the table TALL to WIDE
dt << Split(
       Split By( :RecipeStepId, :ParameterName, :AggregateFunction ),
       Split( :Value ),
       Group( :Recipe, :ProcessTime, :Tool, :Chamber, :Lot, :WaferScribe ),
       Output Table( "AggWide" ),
       Remaining Columns( Drop All ),
       Sort by Column Property,
       dt << sort( by( :Recipe, :Tool, :Chamber, :Lot, :WaferScribe ))
); dtAggWide = current data table(); ColNamesList = dtAggWide << get column names(string, continuous); //get the column names of the WIDE table //Create an empty list for the matching columns RecipeStepList = {}; // Find matching column names For( i = 1, i <= N items( RecipeStepIndex ), i++, For( j = 1, j <= N Items( ColNamesList ), j++, If( Contains( ColNamesList[j], RecipeStepIndex[i] ), Insert Into( RecipeStepList, ColNamesList[j] ), ); ); ); // If groups of columns are found, create Col groupings If( N Items( RecipeStepList ) > 0, dtAggWide << select columns( RecipeStepList ); dtAggWide << group columns(); );
11 REPLIES 11

Re: Script to loop thru and group columns by name, dynamically

Any way to make this search for a specific character, then use that as the group name? That way its a dynamic length for the first section?

jthi
Super User

Re: Script to loop thru and group columns by name, dynamically

You would modify the part where col_group is determined and then continue accordingly.

-Jarmo