How to quickly calculate the total number of column values >2?The calculation seems simple.But I didn't get the quick way:
Calculate the total number of >2 in each column, and get the new table.
Thanks!
dt = Open( "$SAMPLE_DATA\Data\Missing Data Pattern.jmp" );

ScriptingRe: How to quickly calculate the total number of column values >2?Please find one way (no doubt of many). Use 'Help > Scripting Index' to figure out how it works and how to improve it.
NamesDefaultToHere(1);
// Make a table with some (integer) values
nr = 10;
nc = 5;
dt = AsTable(J(nr, nc, RandomInteger(1, 5)));
dt << setName("Integers Between 1 and 5");
// Start here . . .
dt = CurrentDataTable();
// Get the data into a matrix
m = dt << getAsMatrix;
// Only keep values above the threshold (of 2)
m[Loc(m <= 2)] = .;
// Set all remaining values to 1
m =!IsMissing(m);
// Sum every column, and make a table
dt2 = AsTable(VSum(m));
dt2 << setName("Number of Values Above 2");