prepare some data:
//prepare:
Names Default to Here(1);
dt0 = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt = dt0 << Split(
Split By( :age, :sex ),
Split( :height ),
Remaining Columns( Drop All )
);
dt << new column ("sample", set each value(row()));
Now, let's stack it:

- use Eliminate missing rows( 1 )
to get rid of empty entries
- use text to column to split the 2 grouping variables:

if you prefer JSL:
// create stacked table
stacked = dt <<
Stack(
columns(
:"12 F"n, :"12 M"n, :"13 F"n, :"13 M"n, :"14 F"n, :"14 M"n, :"15 F"n,
:"15 M"n, :"16 F"n, :"16 M"n, :"17 F"n, :"17 M"n
),
Stack By Row( 0 ),
Eliminate missing rows( 1 )
);
stacked << Text to Columns( columns( :Label ), Delimiters( " " ) );