I had some old code that might help. Perhaps there is a better way now:
// ian.cox@jmp.com: 23Jun2012
NamesDefaultToHere(1);
// **********************************************************************************************
// Given a table (dt), a list of grouping columns therein (gCols), and a character response
// column (rCol), aggregates the latter into a multiple response column
// **********************************************************************************************
mrSummarize =
Function({dt, gCols, rCol}, {Default Local},
// Summarize using the specified grouping columns to get dt2
dt2 = dt << Summary(Group(gCols));
dt2 << setName("Multiple Response Summary of "||(dt << getName));
// Loop over the rows of dt2 and build a new column with the multiple response values:
// Exploit the linking between dt2 and dt to do this
dt2 << newColumn(rCol, Expression, None);
for(r2=1, r2<=NRow(dt2), r2++,
dt2 << clearSelect;
dt2 << selectRows(Matrix({r2}));
r = dt << getSelectedRows;
// Response values are initially put in a list to make getting the unique values easier
mr2 = {};
for(i=1, i<=NRow(r), i++,
InsertInto(mr2, Column(dt, rCol)[r[i]]);
);
// Force the values in the list to be unique
mr2 = associativeArray(mr2) << getKeys;
// Put the list of unique values in the table
Column(dt2, rCol)[r2] = mr2;
);
dt2 << clearSelect;
// Now need to 'unpack' each list to get values suitable for the 'Multiple Response' modeling type
allLists = Column(dt2, rCol) << getValues;
for(r2=1, r2<=NRow(dt2), r2++,
mr2 = allLists[r2];
for(i=1, i<=NItems(mr2), i++,
if(i==1,
str2 = mr2[i],
str2 = str2 || ", " || mr2[i];
);
);
allLists[r2] = str2;
);
Column(dt2, rCol) << setDataType("Character");
Column(dt2, rCol) << setModelingType("Multiple Response");
Column(dt2, rCol) << setValues(allLists);
dt2;
);
// Sample table
dt = New Table( "Data",
Add Rows( 3 ),
New Column( "Lot",
Numeric,
"Nominal",
Format( "Best", 12 ),
Set Values( [1, 1, 2] )
),
New Column( "Wafer",
Numeric,
"Nominal",
Format( "Best", 12 ),
Set Values( [2, 2, 1] )
),
New Column( "Response",
Character,
"Nominal",
Set Values( {"Green", "Red", "Blue"} )
)
);
// Try out the function
mrSummarize(dt, {"Lot", "Wafer"}, "Response");