First I strongly suggest checking out JMP Scripting guide: JMP15 Scripting Guide and Scripting Index found from Jmp / Help / Scripting Index. These are very good sources for JSL scripting.
To do this task you won't need any jsl:
1. Let's start with the example table you provided us with two missing values
2. Create a summary of the table with N Missing with Height as statistics and SUB_ID and ID as Group
3. Create new Formula by selecting N Rows and N Missing(HEIGHT) columns
4. Change format to Percent from Column Properties and rename columns as needed
Based on these steps you could also fairly easily use JMPs provided functionality to show scripts needed for steps to change this manual process to automated process (small changes should be done to make it more robust).
And for your questions 1 & 3:
1. It depends a lot how you create/open/get your datatables. If you always have the same name, you could reference that but I wouldn't trust that in long run as it is so easy to create multiple datatables with same name and JMP will add indexing after the names. But these can be referenced by Datatable(nameofdatatable).
3. You can get list of datatables with Get Data Table List(). Loop over datatables and close unnecessary ones. But in my opinion you should always close the datatable you won't need as soon as it is possible with Close(reference to datatable, No save).
Example script to perform the task:
Names Default To Here(1);
//create example data and add reference to dt variable
dt = New Table("exampledata",
Add Rows(8),
Compress File When Saved(1),
New Column("ID",
Numeric,
"Nominal",
Format("Best", 12),
Set Values([1, 1, 1, 1, 2, 2, 2, 2])
),
New Column("SUB_ID",
Character,
"Nominal",
Set Values({"A", "A", "B", "B", "A", "A", "B", "B"})
),
New Column("HEIGHT",
Numeric,
"Continuous",
Format("Best", 12),
Set Values([10, 11, ., 9, ., 12, 8, 12])
)
);
//note Link to original data table(0)
//dt_summary is reference to the new Summary table
dt_summary = dt << Summary(
Group(:ID, :SUB_ID),
N Missing(:HEIGHT),
Freq("None"),
Weight("None"),
Link to original data table(0),
output table name("Main Table Summary")
);
//close unnecessary datatable
Close(dt, no save);
//add new column with formula
dt_summary << New Column("Percent Missing",
Numeric,
"Continuous",
Format("Percent", 12, 0),
Formula(:Name("N Missing(HEIGHT)") / :"N Rows"),
);
//rename columns
Column(dt_summary, "N Rows") << Set Name("Total No of Rows");
Column(dt_summary, "N Missing(HEIGHT)") << Set Name("No of Rows with Missing Data");
-Jarmo