Publication date: 07/08/2024

Transpose a Data Table

The Transpose message creates a new data table by flipping a data table on its side, interchanging rows for columns and columns for rows. If you specify no rows, Transpose() uses the selected rows. If no rows are selected, it uses all rows.

dt << Transpose(
	"private", "invisible",
	columns( columns ),
	Rows( row matrix ),
	By ( column ),
	Label column name( "name" ),
	Output Table( "name" )
);
dt << Transpose(
	Columns( columns ),
	Rows( row matrix ),
	Output Table Name( "name" )
);

The following example transposes the height and weight columns in the Big Class.jmp sample data table:

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
tranDt = dt << Transpose( Columns( :height, :weight ),
	Output Table Name( "Transposed Columns" ) );

Note: The simple transpose command dt << Transpose brings up the Transpose window. If you do not want the window to appear, invoke the transpose as dt << Transpose(no option).

Want more information? Have questions? Get answers in the JMP User Community (community.jmp.com).