Re: Creating a new file for a subset of cases/IDs

Posted by Jon Peck on
URL: http://spssx-discussion.165.s1.nabble.com/Creating-a-new-file-for-a-subset-of-cases-IDs-tp5740376p5740380.html

Here is a simple solution using the SPSSINC TRANS extension command, which you can install if you don't already have it from the Extensions > Extension Hub menu.

Suppose you have a dataset named subset containing the cases  you want to select from and an id variable named id in both datasets.  I'll assume that it is numeric, but if it is a string that's an easy adjustment.
Then, with the main dataset active, run this command

spssinc trans result=insubset
/initial "extendedTransforms.vlookup ('id','id','subset')"
/formula func(id).

This produces a variable named insubset that will be the id number if the case is in the subset dataset and otherwise system missing.  So then you can just select on a not missing condition for that variable in the main dataset
(and drop any variables you don't want).  Just be sure to save this under a different file name so that you don't lose the main data.

On Mon, Apr 5, 2021 at 12:09 PM Oliver <[hidden email]> wrote:
Hi everyone,

I have a dataset (Dataset 1) with 3000 different cases (i.e., IDs) and let's
say, two variables (y1, y2). I would like to create a new dataset (Dataset
2) that includes data for y1 and y2, but only for a subset of IDs from
Dataset 1.  I've created Dataset 2 with only the subset (i.e., n = 1500) of
IDs of interest and then tried to use the "Merge file-->Add variables", but
the newly created dataset (i.e., Dataset 2) always generates 3000 cases, not
just the 1500 that I need.

Any assistance would be greatly appreciated.
Thanks in advance.
O.



--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD


--
Jon K Peck
[hidden email]

===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD