|
Re: MERGING PR and IR data [message #18196 is a reply to message #18195] |
Thu, 10 October 2019 10:28 |
Mlue
Messages: 92 Registered: February 2017 Location: North West
|
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.
***************************************************.
|
|
|
|