Have you thought about row states: Hide & Exclude effectively create a subset for analysis without spawning new (or many) data tables? This is a no scripting option that will also limit file sprawl.
This would be your alternative method/ except
no need to step 1 "save as", and
instead of step 5/delete it would be right click hide and exclude (also in columns menu).
Since you mentioned doing this frequently- a few pointers for managing hidden/excluded row states:
- If the selection can be done with column menu/ data filter for "show" and "include" then red triangle "save script to data table" and pick a descriptive name for the subset. Clear row states when done, and re-run the script when this subset is needed again.
Or- make Row State Columns for each subset...
The Row State type data column can save all row state information including hidden/excluded, but also selected and row marker/color
Example Below - sample file Big Class with two Row state columns added.
Subset #1: 13 year olds
- Select 13 year olds, right click select matching, right click invert selection
- Right Click Hide/Exclude the non 13's- the Subset of 13 year olds is now ready for analysis.
To preserve and return to this grouping
- Make a new column of Data Type Row State (named RS_13)
- Just for grins set 13 year old row markers to purple squares
- Left Click on the star of RS_13 in columns pane- copy from row states (this sends the current row states to RS_13 column)
- Protip- Column info- engage "Lock" because it is easy to inadvertently over-write
Also did this for a second subset sex=F, Notice how the row 3 selection is part of the saved row state.
- To deploy, from Row state red star, left click "Copy to Row States". (as illustrated)