Here are few options, but it is very easy to come up with even more (also I'm not sure what would be the issue of using subset as you can create it as private and close it immediately after you have the subset)
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
groupcol = "sex";
// Filter
dt_filter = dt << Summary(
Local Data Filter(
Add Filter(
columns(Transform Column("Row", Formula(Row()))),
Where(Transform Column("Row", Formula(Row())) < 25)
)
),
Group(Eval(groupcol)),
Freq("None"),
Weight("None"),
Link to original data table(0),
Output table("1")
);
// Exclude
dt << Select Where(Row() >= 25) << Hide and Exclude(1);
dt_exclude = dt << Summary(
Group(Eval(groupcol)),
Freq("None"),
Weight("None"),
Link to original data table(0),
Output table("2")
);
dt << Clear Row States;
// SQL
dt_sql = Query(
Table(dt, "bc"),
Eval Insert("\[
SELECT ^groupcol^, COUNT(rowid) "N Rows"
FROM bc
WHERE ROWID < 25
GROUP BY ^groupcol^
]\")
);
dt_sql << Set Name("3");
// Summarize and transform (could also use exclude)
dt << Transform Column("A", Formula(If(Row() < 25, 1, .)));
Summarize(dt, groups = By(Eval(groupcol)), counts = Sum(:A)); // Summarize requires numeric columns
dt_summarize = New Table("4",
New Column(groupcol, Character, Nominal, Values(groups)),
New Column("N Rows", Numeric, Continuous, Values(counts))
);
dt << Delete Columns(:A);
Write();
-Jarmo