cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Due to the recently reported Microsoft outage, users may be temporarily unable to access My JMP or experience a delay receiving their verification codes. If you have previously installed JMP on your computer, this outage should not impact your ability to access the software. My JMP services will be restored as soon as Microsoft resolves this issue.
  • Image to Table JMP extension imports single or batch images as data tables. Useful to extract curves from pictures or convert image data to curve data to use in analyses like Functional Data Explorer. Download and install the extension.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar

Exporting full LCA dataset to CSV/Excel

I conducted an LCA analysis on survey questions. In the "parameter estimates" section of the generated report, there is a table. When I export it, it doesn't export the merged cells on top. For example:

Cluster 1:  [Top Column: State]

                   [AZ] [VA], [DC], [TX]

 

It only exports the cluster, and the parameter estimates for [AZ] [VA], [DC], [TX]. I want to export every visible thing, including the top column with merged cells. 

2 REPLIES 2
txnelson
Super User

Re: Exporting full LCA dataset to CSV/Excel

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

and output the Parameter Estimates table with the Spanning Headers prefixed to each column

txnelson_2-1707103752206.png

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

Re: Exporting full LCA dataset to CSV/Excel

That is impressive @txnelson you have no idea how much time you have helped me save. Kudos to you, sir!

Recommended Articles