I hope someone in the Community has a better solution than what I have come up with. I am not aware of a direct way to add the spanning headers to the column headers in an output data table. However I have written an example script that can do what you want.
It takes an LCA analysis output
![txnelson_0-1707103154843.png txnelson_0-1707103154843.png](https://community.jmp.com/t5/image/serverpage/image-id/60852iD4BFB70BBF9D5E2A/image-dimensions/644x413?v=v2)
and output the Parameter Estimates table with the Spanning Headers prefixed to each column
![txnelson_2-1707103752206.png txnelson_2-1707103752206.png](https://community.jmp.com/t5/image/serverpage/image-id/60854i9A0B109DEE6437DB/image-dimensions/851x120?v=v2)
Here is the example script
Names Default To Here( 1 );
// Run a LCA
dt = Open( "$SAMPLE_DATA/Car Poll.jmp" );
dt << Latent Class Analysis(
Y( :sex, :marital status, :country, :size, :type ),
Set Random Seed( 12345 ),
Number of Clusters( 3 ),
);
// Create an output table will all header names in each column's name
obj = current report()[OutlineBox(1)];
// Get the number of tiles that span across columns
numSpans = Length( (obj << xpath( "//ColSpanBox" )) );
// Loop across the spanning titles and add the title as a prefix to the column name
For( span = 1, span <= numSpans, span++,
// Get the header
theHeading = obj["Parameter Estimates"][Col Span Box( span )] << get heading;
// Get the column names for the current spanning header
theCols = obj["Parameter Estimates"][Col Span Box( span )] << get text;
// Loop across each column name in the span
subColNum = 1;
While( Try( Word( subColNum, theCols, "\!n\!t\!r" ), "" ) != "",
targetCol = Word( subColNum, theCols, "\!n\!t\!r" );
// Loop across all numeric column and when a match is found change the column name
numCol = 2;
While(
Try( obj["Parameter Estimates"][Number Col Box( numCol )] << get heading, "" )
!= "",
theNumberColBoxHeader = obj["Parameter Estimates"][Number Col Box( numCol )]
<< get heading;
If( targetCol == theNumberColBoxHeader,
obj["Parameter Estimates"][Number Col Box( numCol )] <<
set heading( theHeading || " " || targetCol )
);
numCol++;
);
subColNum++;
);
);
// Create the output data table
obj["Parameter Estimates", Table Box( 1 )] << Make into data table;
Jim