How to discard last 'N' records using Select node in SPSS modeler?

140 Views Asked by At

The title says it all. Working on a use case where I need to trim both the top and bottom of a dataset at every new run. It is not fixed how much will be removed every run, just 'N' amount of records.

I was able to discard the first N records using this post. However, I am not sure how the last few can be removed. I looked up the documentation and the negative sign does not work (atleast the way I need it to). This is my first time using SPSS, so any help is welcome. Thanks!

1

There are 1 best solutions below

0
Kenneth On

The easiest way to do this would probably be to sort your data so that the last 5 records become the first 5 records and then follow the instructions from the referenced post.

Alternatively, you can use the Aggregate node to get the total number of records in the dataset and then merge that number back into your primary dataset. You can use the Select node with the condition (count - @INDEX - 1) <= N where 'count' is the field with the total number of records in the dataset and N is the number of records that you are looking to discard.