SPSS - Merging Household variables with Individual Women's dataset [message #2404] |
Fri, 13 June 2014 05:02 |
aligazan
Messages: 24 Registered: June 2014 Location: UK
|
Member |
|
|
Hello,
I do realise that there have already been lots of posts on this subject. I have read them all, but I am still struggling to understand exactly how to do this on SPSS.
I want to add variables from the HH dataset into the Women's dataset (for Mali 2006). The particular variables I am interested in are to do with the relationships of the household members, and I would ultimately like to know which relatives each woman in the individual dataset, is living with (e.g. no other adult, living with husband, with co-wife, with parent, with parent-in-law, etc.).
This relationship is found from the variables HV101$01 etc. on the HH dataset.
I have seen the code below, but as I am relatively new to SPSS I have been unable to work out how to adapt this for the objective that I am trying to achieve.
I would really appreciate any help with this. THANKS!
Below is an example syntax for merging the HIV Test data with the Women's data in SPSS.
GET FILE='C:\DATAUSER\ZMAR51FL.SAV'.
SORT CASES BY
HIVCLUST (A) HIVNUMB (A) HIVLINE (A).
SAVE OUTFILE='C:\DATAUSER\HIV.sav'
/COMPRESSED.
GET FILE='C:\DATAUSER\ZMIR51FL.SAV'.
SORT CASES BY
V001 (A) V002 (A) V003 (A) .
SAVE OUTFILE='C:\DATAUSER\WOMEN.sav'
/RENAME(V001 V002 V003=
HIVCLUST HIVNUMB HIVLINE)
/COMPRESSED.
GET FILE='C:\DATAUSER\WOMEN.sav'.
MATCH FILES /FILE=*
/TABLE='C:\DATAUSER\HIV.sav'
/BY HIVCLUST HIVNUMB HIVLINE.
EXECUTE.
SAVE OUTFILE='C:\DATAUSER\ZMAR_IR.SAV'
/COMPRESSED.
|
|
|
|
Re: SPSS - Merging Household variables with Individual Women's dataset [message #2457 is a reply to message #2405] |
Fri, 20 June 2014 06:42 |
aligazan
Messages: 24 Registered: June 2014 Location: UK
|
Member |
|
|
Dear Bridgette,
Thanks so much for your reply. I have done as you suggested but I get the message shown below. Does this mean there is a correction needed to the syntax?
Thanks again so much for your help.
Janet
Variable(s) incorrectly used in 'BY'
------Input1------ ------Input2------
Result Type Variable name Type Variable name
HHID s12 HHID s36 HHID
Codes: num = numeric; sn = string of length n
>Error # 5126
>The BY variable list is invalid. All the variables on the list must exist on
>all the input files, and each variable must be of the same type (numeric, or
>strings of the same length) on all the input files.
>Execution of this command stops.
Variable(s) with conflicting type:
-------Input1------- -------Input2-------
Result Type Variable name Type Variable name
HHID s12 HHID s36 HHID
Codes: num = numeric; sn = string of length n
>Error # 5127
>Mismatched variable types on the input files.
>Note # 5145
>The working file has been restored, and subsequent commands may access the
>working file.
EXECUTE.
SAVE OUTFILE='C:\Users\Janet\Documents\0 MPhil\DHS\Mali datasets\MLIR52sv\MLhR_iR.SAV'
/COMPRESSED.
|
|
|
|
Re: SPSS - Merging Household variables with Individual Women's dataset [message #2464 is a reply to message #2458] |
Mon, 23 June 2014 13:43 |
Bridgette-DHS
Messages: 3203 Registered: February 2013
|
Senior Member |
|
|
Where are you getting the variables: "s12" and "s36" from (in your syntax)?
The syntax we posted seems perfectly fine, and all you have to do is modify the file names and the path for the file location. See modified syntax below:
get file = 'c:\testing\MLIR52FL.SAV'.
STRING HHID (A12).
COMPUTE HHID = SUBSTR(CASEID,1,12).
VARIABLE LABELS HHID 'Household ID' .
EXECUTE .
MATCH FILES /FILE=*
/TABLE='c:\testing\MLHR52FL.SAV'
/BY hhid.
EXECUTE.
SAVE OUTFILE='c:\testing\HR_IR.SAV'
/COMPRESSED.
[Updated on: Thu, 25 June 2015 13:38] Report message to a moderator
|
|
|