- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Delete column by scipt
Hello
I have written a script for deleting the column "Missing(Result)" in the table
My problem is that sometimes I do not have the column "Missing(Result)" and I'm receiving an error at this moment.
Can you assist me with what I need to add to my script that will delete the column if it exists in my table.
And if it doesn't exist, just skip this request?
dt << delete column (column ("Missing(Result)"));
1 ACCEPTED SOLUTION
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Delete column by scipt
Use << Get Column Names(String) to get list of column names and then if statement with Contains to check for the specific name
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
col_names = dt << Get Column Names(String);
If(Contains(col_names, "Missing(Result)"),
dt << Delete Columns("Missing(Result)")
);
-Jarmo
1 REPLY 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Delete column by scipt
Use << Get Column Names(String) to get list of column names and then if statement with Contains to check for the specific name
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
col_names = dt << Get Column Names(String);
If(Contains(col_names, "Missing(Result)"),
dt << Delete Columns("Missing(Result)")
);
-Jarmo