Apply Dictionary: One to Many with Diferent Variables

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Apply Dictionary: One to Many with Diferent Variables

M'hammed Abdous
Dear all,


Does anyone have a syntax file that I can use to update several dataset
files, using a single dataset file. The dataset source has different
variables (name, type, label and value) than the target files.



Thank you very much in advance,


M'hammed.

[hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Apply Dictionary: One to Many with Diferent Variables

Hector Maletta
         M'Hammed,
         You have to give the variables the same name. When you merge files,
the resulting variable takes the value contained in the first file
mentioned. You can rename the variables first, then merge the files, and you
get also the opportunity to rename variables as part of the merging process.
SPSS has no way of knowing in advance that two variables with different
names are really the same, unless you give them the same name in advance.
         When you rename the variables, remember that string variables have
to be the same length to be regarded as the same variable. If two string
variables that are actually the same are defined with different length in
two files, redefine one of them (possibly lengthening the shorter one, to be
on the safe side) in order that the two have the same length, prior to the
merging. And the files must be sorted by the same key variables.
         Example:
         GET FILE 'FILE1.SAV'.
         RENAME VARIABLES (A B C = D E F).
         SORT CASES BY D G Z.
         SAVE OUTFILE 'FILE1.SAV'.

         GET FILE 'FILE2.SAV'.
         SORT CASES BY D G Z.
         SAVE OUTFILE 'FILE2.SAV'.

         MATCH FILES /FILE 'FILE2.SAV'/FILE 'FILE1.SAV'/BY D G Z.
         SAVE OUTFILE 'NEWFILE.SAV'.
         In this case, the variables common to FILE 1 and FILE 2 will have
in new file the values taken from FILE 2, because FILE 2 was named first in
the MATCH FILES command.
         Hector

         -----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
M'hammed Abdous
Sent: 03 July 2007 09:44
To: [hidden email]
Subject: Apply Dictionary: One to Many with Diferent Variables

         Dear all,


         Does anyone have a syntax file that I can use to update several
dataset
         files, using a single dataset file. The dataset source has
different
         variables (name, type, label and value) than the target files.



         Thank you very much in advance,


         M'hammed.

         [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: More - Apply Dictionary: One to Many with Diferent Variables

Hector Maletta
In reply to this post by M'hammed Abdous
         Two more points:
         - Apply Dictionary has nothing to do with this. When you merge
files, the first file named in the command transfers all the variable
properties (name, labels, formats, etc) to the resulting variable in the
merged file.
         - You speak of "one to many". This does not mean "one file to many
files" but "one case to many cases". For instance, if you have a file with
data about a number of hospitals, and another about a large number of
patients of those very hospitals, you can assign to each patient the
attributes of the corresponding hospital. Thus the values of ONE hospital
will be transferred to MANY patients. In your case I think you are trying to
match files concerning the same type of cases. For instance, if you have two
or three files containing data about the same group of persons, you are
trying to match ONE to ONE, data from ONE person in one file to ONE person
(the same person) in another file.
         See please whether the subject line of your posting is correct.

         Hector

         -----Original Message-----
From: Hector Maletta [mailto:[hidden email]]
Sent: 03 July 2007 11:24
To: 'M'hammed Abdous'; '[hidden email]'
Subject: RE: Apply Dictionary: One to Many with Diferent Variables

                  M'Hammed,
                  You have to give the variables the same name. When you
merge files, the resulting variable takes the value contained in the first
file mentioned. You can rename the variables first, then merge the files,
and you get also the opportunity to rename variables as part of the merging
process. SPSS has no way of knowing in advance that two variables with
different names are really the same, unless you give them the same name in
advance.
                  When you rename the variables, remember that string
variables have to be the same length to be regarded as the same variable. If
two string variables that are actually the same are defined with different
length in two files, redefine one of them (possibly lengthening the shorter
one, to be on the safe side) in order that the two have the same length,
prior to the merging. And the files must be sorted by the same key
variables.
                  Example:
                  GET FILE 'FILE1.SAV'.
                  RENAME VARIABLES (A B C = D E F).
                  SORT CASES BY D G Z.
                  SAVE OUTFILE 'FILE1.SAV'.

                  GET FILE 'FILE2.SAV'.
                  SORT CASES BY D G Z.
                  SAVE OUTFILE 'FILE2.SAV'.

                  MATCH FILES /FILE 'FILE2.SAV'/FILE 'FILE1.SAV'/BY D G Z.
                  SAVE OUTFILE 'NEWFILE.SAV'.
                  In this case, the variables common to FILE 1 and FILE 2
will have in new file the values taken from FILE 2, because FILE 2 was named
first in the MATCH FILES command.
                  Hector

                  -----Original Message-----
         From: SPSSX(r) Discussion [mailto:[hidden email]] On
Behalf Of M'hammed Abdous
         Sent: 03 July 2007 09:44
         To: [hidden email]
         Subject: Apply Dictionary: One to Many with Diferent Variables

                  Dear all,


                  Does anyone have a syntax file that I can use to update
several dataset
                  files, using a single dataset file. The dataset source has
different
                  variables (name, type, label and value) than the target
files.



                  Thank you very much in advance,


                  M'hammed.

                  [hidden email]