0
$\begingroup$

I want to split my data set into two files, 50% of random cases in each file. I would like to use the first set as a training set and the second one for testing my prediction model.

Following is an example: 10 cases (1,2,3,4,5,6,7,8,9,10), I want to split it into 2 files with 5 random cases in each file (1,3,6,7,9) and (2,4,5,8,10).

How can I do this using Data>Select Cases option? I am able to generate a single set of 50% random cases but how do I test the remaining 50% of cases. SPSS gives an output of only 1 file

$\endgroup$

closed as off-topic by Nick Cox, Sven Hohenstein, ttnphns, Sycorax, Peter Flom Feb 18 '16 at 19:33

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question appears to be off-topic because EITHER it is not about statistics, machine learning, data analysis, data mining, or data visualization, OR it focuses on programming, debugging, or performing routine operations within a statistical computing platform. If the latter, you could try the support links we maintain." – Nick Cox, Sven Hohenstein, ttnphns, Sycorax, Peter Flom
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ This Q is both off-topic and also unclear (for example, may the two subsamples intersect by their case composition or not?). $\endgroup$ – ttnphns Feb 18 '16 at 19:00
1
$\begingroup$

Data -> Select Cases. Choose "Random sample of cases". You can either specify approximately 50% of the cases (SPSS Syntax below) or a specific number. You should tick the option in the Output box to "Copy selected cases to a new dataset" and name the new dataset (this is also in the syntax below).

DATASET ACTIVATE DataSet1.
DATASET COPY  dataset2.
DATASET ACTIVATE  dataset2.
FILTER OFF.
USE ALL.
SAMPLE  .50.
EXECUTE.
DATASET ACTIVATE  DataSet1.
$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.