JMP 17.2 > CUSTOMIZED REPORT > STRING COL BOX > How do I distribute a long list into multiple columns?Hi JMP Community,
I am experimenting with a custom report (see below), for which I would like to distribute lists of varying length into multiple columns in a String Col Box(). For example, for the list shown in the script, I would like to distribute its elements into 4 columns of 17 lines.
The simplified script (I stripped everything but the essential lines):
Names Default to Here (1);
datastring = { "ASPM", "AURKA", "AURKB", "BIRC5", "BUB1", "BUB1B", "CCNB1", "CCNB2", "CCNE2", "CDC20", "CDC6", "CDCA2", "CDCA5", "CDCA8", "CDK1", "CDT1",
"CENPE", "CENPF", "CENPK", "CENPN", "CENPS", "CENPW", "DIAPH3", "DLGAP5", "ECT2", "ESCO2", "FAM83D", "HJURP", "KIF11", "KIF14", "KIF15", "KIF18A",
"KIF18B", "KIF23", "KIF2C", "KIF4A", "KIFC1", "KNL1", "MAD2L1", "MKI67", "NCAPG", "NCAPH", "NDC80", "NEK2", "NUF2", "NUSAP1", "OIP5", "PLK1", "PRC1", "PSRC1",
"PTTG1", "RACGAP1", "SGO1", "SGO2", "SKA1", "SKA3", "SPAG5", "SPC24", "SPC25", "TACC3", "TOP2A", "TPX2", "TRIP13", "TTK", "UBE2C", "UHRF1", "ZWILCH", "ZWINT"};
// The length of the list varies from 4 to 125 items, depending on the specific report
rep_w = New Window ("REPORT TEST",
mainframe = HList Box("DATA",
text_data = TableBox (Col Span Box ("MEMBERS", String Col Box ("Genes", datastring)))
)
);
Thank you.
Best regards,
TS
Automation and ScriptingSharing and Communicating ResultsWindowsRe: JMP 17.2 > CUSTOMIZED REPORT > STRING COL BOX > How do I distribute a long list into multiple columns?Here is one way to do what you want. I broke the code into individual hardcoded statements assuming you will want to build some looping logic into the final code.

theList=rep_w[stringcolbox(1)]<<GET></GET>
Re: JMP 17.2 > CUSTOMIZED REPORT > STRING COL BOX > How do I distribute a long list into multiple columns?Hi txnelson,
Thank you for your feedback, but this provides a solution to parsing input from a String Col Box into a Table. I am actually looking for something else: how to parse a list into multiple columns within a String Col Bax structure?
Best,
TS
Re: JMP 17.2 > CUSTOMIZED REPORT > STRING COL BOX > How do I distribute a long list into multiple columns?Is this what you want

Names Default to Here (1);
datastring = { "ASPM", "AURKA", "AURKB", "BIRC5", "BUB1", "BUB1B", "CCNB1", "CCNB2", "CCNE2", "CDC20", "CDC6", "CDCA2", "CDCA5", "CDCA8", "CDK1", "CDT1",
"CENPE", "CENPF", "CENPK", "CENPN", "CENPS", "CENPW", "DIAPH3", "DLGAP5", "ECT2", "ESCO2", "FAM83D", "HJURP", "KIF11", "KIF14", "KIF15", "KIF18A",
"KIF18B", "KIF23", "KIF2C", "KIF4A", "KIFC1", "KNL1", "MAD2L1", "MKI67", "NCAPG", "NCAPH", "NDC80", "NEK2", "NUF2", "NUSAP1", "OIP5", "PLK1", "PRC1", "PSRC1",
"PTTG1", "RACGAP1", "SGO1", "SGO2", "SKA1", "SKA3", "SPAG5", "SPC24", "SPC25", "TACC3", "TOP2A", "TPX2", "TRIP13", "TTK", "UBE2C", "UHRF1", "ZWILCH", "ZWINT"};
// The length of the list varies from 4 to 125 items, depending on the specific report
rep_w = New Window ("REPORT TEST",
mainframe = HList Box("DATA",
text_data = TableBox (Col Span Box ("MEMBERS"))
)
);
text_data<<APPEND></APPEND>Re: JMP 17.2 > CUSTOMIZED REPORT > STRING COL BOX > How do I distribute a long list into multiple columns?@Thierry_S
Here is a generalized way to do it in JSL. I created a function the requires an original list and an integer. The function splits the original list into n number of smaller lists and returns the list of lists. In the case that the number of items in the original list is not evenly divisible by n, the nth column will have the balance of items. This keeps the function general in case you want to use it again for a table with more or less columns.
The table is then created by appending each list as a string col box to a table box:
Names Default to Here (1);
splitList_fxn = function( {list, n},
// split a list into into n evenly divided lists and return a list of lists
// if list items/n is not an integer, place the extra items in the nth column
{i,j,k,n,lists,thisList,listSize,items},
lists = {};
items = n items( list );
listSize = round( items/n );
k = 0; // counter
for( i = 1, i <= n, i++,
thisList = {};
if( i != n,
// all but the last list
for( j = (k*listSize)+1, j <= listSize*i, j++,
insert into( thisList, list[j] )
),
// last list will be the remaining items in case there is a remainder
for( j = (k*listSize)+1, j <= items, j++,
insert into( thisList, list[j] )
)
);
k++;
insert into( lists, eval list( list( thisList ) ) )
);
return( lists )
);
// number of columns
n = 4;
// original list
datastring = { "ASPM", "AURKA", "AURKB", "BIRC5", "BUB1", "BUB1B", "CCNB1", "CCNB2", "CCNE2", "CDC20", "CDC6", "CDCA2", "CDCA5", "CDCA8", "CDK1", "CDT1",
"CENPE", "CENPF", "CENPK", "CENPN", "CENPS", "CENPW", "DIAPH3", "DLGAP5", "ECT2", "ESCO2", "FAM83D", "HJURP", "KIF11", "KIF14", "KIF15", "KIF18A",
"KIF18B", "KIF23", "KIF2C", "KIF4A", "KIFC1", "KNL1", "MAD2L1", "MKI67", "NCAPG", "NCAPH", "NDC80", "NEK2", "NUF2", "NUSAP1", "OIP5", "PLK1", "PRC1", "PSRC1",
"PTTG1", "RACGAP1", "SGO1", "SGO2", "SKA1", "SKA3", "SPAG5", "SPC24", "SPC25", "TACC3", "TOP2A", "TPX2", "TRIP13", "TTK", "UBE2C", "UHRF1", "ZWILCH", "ZWINT"};
// The length of the list varies from 4 to 125 items, depending on the specific report
// split the original list into n lists of equal size
col_lists = splitList_fxn( datastring, n );
// create table box and append string col boxes with each list
table = tablebox();
for each( {list,index}, col_lists,
table << append( string col box( "Col " || char(index), list ) )
);
// create report window
rep_w = new window( "REPORT TEST",
mainframe = HList Box("DATA",
table
)
);
n = 4

n = 8

Re: JMP 17.2 > CUSTOMIZED REPORT > STRING COL BOX > How do I distribute a long list into multiple columns?splitList_fxn = function( {list, n},
{default local},
lists = {};
Nparts =ceiling(nitems(list)/n);
i=0;
while(nitems(list),
i++;
chunk = remove from (list, 1,Nparts);
Insert Into(lists, eval list({chunk}));
);
if(i<N></N>
Insert Into(lists, eval list({chunk})); ?
It's need till:
Insert Into: Flatten(0|1)