Sorry for not double checking first.
Try the following
names default to here(1);
// source data table
dt = New Table( "source",
Add Rows( 10 ),
New Column( "ID ",
Numeric,
Continuous,
Format( "Best", 5 ),
Set Values( [1, 1, 1, 2, 2, 3, 3, 4, 4, 4] )
),
New Column( "Var1 ",
Numeric,
Continuous,
Format( "Best", 12 ),
Set Values( [1, 1, 1, 0, 0, 1, 1, 0, 1, 0] )
),
New Column( "Var2 ",
Numeric,
Continuous,
Format( "Best", 12 ),
Set Values( [1, 1, 0, 1, 1, 1, 0, 1, 1, 0] )
),
New Column( "Outcome",
Numeric,
Continuous,
Format( "Best", 12 ),
Set Values( [0, 0, 1, 1, 1, 0, 0, 1, 1, 1] )
)
);
// add index column for splitting - no need to sort the table first
dt << new column ("index", formula(Sum( :ID[Index( 1, Row() )] == :ID ) ) );
// now split by index and group by ID
dt << Split(
Split By( :index ),
Split( :Var1, :Var2, :Outcome ),
Group( :ID )
);