The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Data » Merging data files » MERGING PR and IR data
MERGING PR and IR data [message #18195] Thu, 10 October 2019 02:11 Go to next message
aqeelazahra14@yahoo.com is currently offline  aqeelazahra14@yahoo.com
Messages: 5
Registered: December 2014
Member
I want merge individual household data with women data for pakistan using spss. Kindly guide me which key variable should be used.
Re: MERGING PR and IR data [message #18196 is a reply to message #18195] Thu, 10 October 2019 10:28 Go to previous messageGo to next message
Mlue
Messages: 84
Registered: February 2017
Location: Cape Town
Senior Member
Hello,

This might point you in the right direction. I'm not sure if it will exactly work for what you want tot do.


** MERGING PR & IR FILES ON SPSS.

** ===================================================================== **.

**** OPEN THE IR FILE ****.
GET
  FILE='C:\Users\Tsawe\Documents\PAKISTAN 2017-18 DHS\PK_2017-18_DHS_SPSS\PKIR71SV\PKIR71FL.SAV'.
DATASET NAME IR_Dataset WINDOW=FRONT.

STRING HHID (A12).
COMPUTE HHID = SUBSTR(CASEID,1,12).

COMPUTE line =V003.

SORT CASES BY V001(A) V002(A) line(A).

SAVE OUTFILE ="C:\Users\Tsawe\Documents\PAKISTAN 2017-18 DHS\PKIR71FLtemp.SAV".

***************************************************.

**** OPEN THE PR FILE ****.
GET
  FILE='C:\Users\Tsawe\Documents\PAKISTAN 2017-18 DHS\PK_2017-18_DHS_SPSS\PKPR71SV\PKPR71FL.SAV'.
DATASET NAME PR_Dataset WINDOW=FRONT.

COMPUTE V001=HV001.
COMPUTE V002=HV002.
COMPUTE line=HVIDX.

************************************************.
SORT CASES hhid (A).

AGGREGATE /OUTFILE=* MODE=ADDVARIABLES OVERWRITE=YES 
      /BREAK hhid  
      /hhsize = nu.
EXECUTE.

COMPUTE hhtag =0. 
      IF $casenum = 1 or hhid ne lag(hhid) hhtag = 1. 
EXECUTE.

COMPUTE pid = 1. 
   IF hhid = lag(hhid) pid = lag(pid) + 1.
EXECUTE.

********************************************.

** REARRANGE DATA. 
ADD FILES FILE * 
   /KEEP HHID hhtag pid hhsize ALL. 
EXECUTE.

********************************************.

SORT CASES BY V001(A) V002(A) line(A).

SAVE OUTFILE = "C:\Users\Tsawe\Documents\PAKISTAN 2017-18 DHS\PKPR71FLtemp.SAV".
DATASET CLOSE IR_Dataset.

***************************************************.

**** THE MERGE (ONE TO MANY) ****.

*MATCH FILES FILE = "C:\Users\Tsawe\Documents\MW_2015-16_DHS_05242018_253_52565\KR_PR DATA\MWKR7HFLtemp.SAV"  /IN=inKRfile
    /TABLE = "C:\Users\Tsawe\Documents\MW_2015-16_DHS_05242018_253_52565\KR_PR DATA\MWPR7HFLtemp.SAV"   /IN=inPRfile
     /BY V001 V002 line.

MATCH FILES FILE="C:\Users\Tsawe\Documents\PAKISTAN 2017-18 DHS\PKIR71FLtemp.SAV"  /IN=inIRfile
  /FILE= "C:\Users\Tsawe\Documents\PAKISTAN 2017-18 DHS\PKPR71FLtemp.SAV"  /IN=inPRfile
  /BY V001 V002 line.
DATASET NAME MERGED_Dataset WINDOW=FRONT.
DATASET CLOSE PR_Dataset.

**********.

FREQUENCIES VARIABLES=inIRfile inPRfile
  /ORDER=ANALYSIS.

**********.

SELECT IF inPRfile EQ 1.
*SELECT IF inIRfile EQ 1.

SAVE OUTFILE = "C:\Users\Tsawe\Documents\PAKISTAN 2017-18 DHS\MERGED_IR_PR_PAKISTAN.SAV".

FREQUENCIES VARIABLES=inIRfile inPRfile V190 HV270 hhtag pid hhsize
  /ORDER=ANALYSIS.

***************************************************.

Re: MERGING PR and IR data [message #18201 is a reply to message #18196] Sun, 13 October 2019 03:12 Go to previous message
aqeelazahra14@yahoo.com is currently offline  aqeelazahra14@yahoo.com
Messages: 5
Registered: December 2014
Member
Thanks for your reply but it is not working. Kindly someone can explain simply that what key variables i should use to merge PR and IR files
Previous Topic: Merge NFHS 4 recode files
Next Topic: Merging from multiple countries
Goto Forum:
  


Current Time: Tue Apr 7 16:39:43 Eastern Daylight Time 2020