- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
subset in JSL -syntax issue
Hi
I'm trying to subset all the data in the row which the value in column: " is rejects?" ==Y to new table called rejects
I try several ways but non of them working and I get the error:
"Unexpected "Split_dt". Perhaps there is a missing ";" or ",".
Line 77 Column 1: ►Split_dt << Select Where( :is rejects? == "Y" );"
this code is part of larger script that create the column :"is rejects?"
when I run the all script I get the error above, but when I run it separately it is working.
what can I do to fix it?
option1:
rejects = Split_dt << Subset(
Where(:is rejects? == "Y"),
Output Table Name("rejects"),
All Columns
);
option2:
Split_dt << Select Where(:is rejects? == "Y");
rejects = Split_dt << Subset(Output Table Name("rejects"), All Columns);
the full script:
Split_dt = Current Data Table();
Split_dt << New Column("is rejects?", character, Formula("N"));
Column(Split_dt, "is rejects?") << Delete Formula;
// Get the number of columns in the data table
numCols = N Cols(Split_dt);
// Iterate over each row in the data table
For Each Row(
// Iterate over each column starting from column 6
For(colIndex = 6, colIndex <= numCols, colIndex++,
// Get the column reference
currentCol = Column(Split_dt, colIndex);
// Check if the value in the current cell is greater than 100 and "is rejects?" is "N"
If(
currentCol[] > 100 & :is rejects? == "N" & Contains(currentCol << Get Name, "BI")
== 0,
// Change the value in the "is rejects?" column to "Y"
:is rejects? = "Y";
// Exit the loop early since we only need one match
Break();
);
)
);
rejects = Split_dt << Subset(
Where(:is rejects? == "Y"),
Output Table Name("rejects"),
All Columns
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: subset in JSL -syntax issue
I usually use Rows() when subsetting specific rows (you can also subset selected rows, but usually you end up performing unnecessary selects in the table when doing this).
This example will subset all rows which have sex == "F"
Names Default To Here(1);
dt = open("$SAMPLE_DATA/Big Class.jmp");
rows_to_subset = dt << get rows where(:sex == "F");
dt_subset = dt << Subset(Rows(rows_to_subset), Output Table("Subset F"));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: subset in JSL -syntax issue
thank you for the quick response.
the solution you suggested give the same error
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: subset in JSL -syntax issue
Which JMP version are you using? Did you try my example script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: subset in JSL -syntax issue
Try
rejects = Split_dt << Subset(
Filtered Rows(:is rejects? == "Y"),
Output Table Name("rejects"),
All Columns
);