Structuring your JSL the way you are, you are taking advantage of some nice JMP features. Writing JSL to create your desired output would require a lot of coding. Below, I have made some minor adjustments to your script that might give you a little more efficient script.
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
d2 = New Table( "tmp" );
k = 1;
For( k = 20, k <= N Row( dt ), k++,
dt << Select Where( k - 20 < Row() <= k );
d3 = dt << Subset( Output Table( "tab" ), Selected Rows( 1 ), selected columns( 0 ), private );
d1 = d3 << Summary(
Sum( height ),
Sum( weight ),
Subgroup( age ),
Freq( 0 ),
Weight( 0 ),
Link to original data table( 0 ),
statistics column name format( "column" )
);
d2 << Concatenate( Data Table( d1 ), Append to first table );
Close( d1, nosave );
Close( d3, nosave );
);
I changed the name of your index variable called "j". This is to avoid possible confusion. JMP has a function named j(). It is a better practice to avoid also having a variable named "j" too.
Jim