Question: How to store each subset after splitting a file

March 26th, 2006

Question: Hi all!

After a SPLIT command applied to my file, I would like each generated subset
of data to be saved in a different .sav file.

Is there an easy way to do that using SAVE or XSAVE?

Even if SPSS can manage each subset separately, I did not find how to save
each subset separately.
Do not hesitate if I am not clear enough or if you need more information.

My data is organized as follows:
Source Destination other variable
david Stefan 123
Nico Bruce 213
Nico Stefan 333
Stefan Nico 2
david Stefan 5
Stefan Nico 56

I want to split my file according to each unique combination
, hence, I use:

SPLIT FILE SEPARATE BY Source Destination.
Hence I have my data sorted as I need:
Source Destination other variable
david Stefan 123
david Stefan 5
Nico Bruce 213
Nico Stefan 333
Stefan Nico 2
Stefan Nico 56

Now, what I need, is to have all the records for each distinct pairto a different file.
Assuming that my first file is called file.sav, I would like to have:
file_david_Stefan.sav with all records with
file_Nico_Bruce.sav with all records with
file_Nico_Stefan.sav with all records with
and so on…
Thanks you for your help.

Answer: Here is the better way.DO IF source=?david? and destination=’Stefan’.
XSAVE OUTFILE=?file_david_Stefan.sav?.
ELSE IF source=?Nico? and destination=’Bruce’.
XSAVE OUTFILE=?file_Nico_Bruce.sav?.
ELSE IF…
etc.

Do you also need an answer on your spss question, submit your question here.

Entry Filed under: 2. Enhancing your data,Questions and answers

2 Comments

  • 1. Carl Maas  |  January 31st, 2007 at 12:54 am

    I recently received a data set with a variable consisting of codes that represent schools. Each case has the school they went to listed by code. The problem is I need to create a new variable that tells me if more than 10 or less than 10 students were in each school. I have run a frequency that gave me the schools with more than 10 students, but when I compute a new variable that codes the >10 schools with a yes (1), I get nothing but zeros in the new variable. Is there a way to create a new variable that counts all the mutually exclusive responses (school codes in this case) and gives a categorical response in the new variable?

  • 2. andris  |  February 2nd, 2007 at 2:11 am

    Hi Carl,

    What I can read from your post, your data file looks like this:

    student_id student_name school_id

    So you have a row per student. If this is this case, it seems very unlogical to me to make a new variable for each student which contains a yes if the school the student went to has more than 10 students. To my logic it is not possible with the compute method to create what you want. Let me know if your data file looks different than what I described here.


Calendar

March 2006
M T W T F S S
    Apr »
 12345
6789101112
13141516171819
20212223242526
2728293031  

Most Recent Posts