/**********************************************************************/ /* Purpose Creates balanced responding person long longitudinal file */ /* using the combined files. */ /**********************************************************************/ /* *******************************************************************************/ /* Section 1: locate datasets, get balanced cases, load renaming macro */ /* *******************************************************************************/ set printback=listing. * (1.1) Files. * (1.1.1) Input: combined files. * You MUST edit the name paths in ALL of Sections 1.1.1 to Section 1.1.4. file handle w1c /name='X:\HILDA\Release 140\Files\SPSS 140c\Combined a140c.sav'. file handle w2c /name='X:\HILDA\Release 140\Files\SPSS 140c\Combined b140c.sav'. file handle w3c /name='X:\HILDA\Release 140\Files\SPSS 140c\Combined c140c.sav'. file handle w4c /name='X:\HILDA\Release 140\Files\SPSS 140c\Combined d140c.sav'. file handle w5c /name='X:\HILDA\Release 140\Files\SPSS 140c\Combined e140c.sav'. file handle w6c /name='X:\HILDA\Release 140\Files\SPSS 140c\Combined f140c.sav'. file handle w7c /name='X:\HILDA\Release 140\Files\SPSS 140c\Combined g140c.sav'. file handle w8c /name='X:\HILDA\Release 140\Files\SPSS 140c\Combined h140c.sav'. file handle w9c /name='X:\HILDA\Release 140\Files\SPSS 140c\Combined i140c.sav'. file handle w10c /name='X:\HILDA\Release 140\Files\SPSS 140c\Combined j140c.sav'. file handle w11c /name='X:\HILDA\Release 140\Files\SPSS 140c\Combined k140c.sav'. file handle w12c /name='X:\HILDA\Release 120\Files\SPSS 120c\Combined l120c.sav'. file handle w13c /name='X:\HILDA\Release 140\Files\SPSS 140c\Combined m140c.sav'. file handle w14c /name='X:\HILDA\Release 140\Files\SPSS 140c\Combined n140c.sav'. file handle master /name='X:\HILDA\Release 140\Files\SPSS 140c\Master n140c.sav' . * (1.1.2) Output: generated renaming program, balanced master file. file handle renprog /name='c:\temp\rename.sps'. file handle balanced /name='c:\temp\balanced.sav'. * (1.1.3) Output: intermediate longitudinal files. file handle w1l /name='C:\temp\w1l.sav'. file handle w2l /name='C:\temp\w2l.sav'. file handle w3l /name='C:\temp\w3l.sav'. file handle w4l /name='C:\temp\w4l.sav'. file handle w5l /name='C:\temp\w5l.sav'. file handle w6l /name='C:\temp\w6l.sav'. file handle w7l /name='C:\temp\w7l.sav'. file handle w8l /name='C:\temp\w8l.sav'. file handle w9l /name='C:\temp\w9l.sav'. file handle w10l /name='C:\temp\w10l.sav'. file handle w11l /name='C:\temp\w11l.sav'. file handle w12l /name='C:\temp\w12l.sav'. file handle w13l /name='C:\temp\w13l.sav'. file handle w14l /name='C:\temp\w14l.sav'. * (1.1.4) Output: final balanced long responding person file. file handle w1w14long /name='C:\temp\w1w14long.sav'. file handle w1w14long_1 /name='C:\temp\w1w14long_1.sav'. /* end dataset location */ * (1.2) Identify cases responding in all waves from the master file. * status codes: 1=face to face interview, 2=telephone interview. get file=master. * for balanced panel (interviewed every wave), remove for unbalanced. select if any(afstatus,1,2) and any(bfstatus,1,2) and any(cfstatus,1,2) and any(dfstatus,1,2) and any(efstatus,1,2) and any(ffstatus,1,2) and any(gfstatus,1,2) and any(hfstatus,1,2) and any(ifstatus,1,2) and any(jfstatus,1,2) and any(kfstatus,1,2) and any(lfstatus,1,2) and any(mfstatus,1,2) and any(nfstatus,1,2). sort cases by xwaveid. save outfile=balanced/keep=xwaveid ahhrpid bhhrpid chhrpid dhhrpid ehhrpid fhhrpid ghhrpid hhhrpid ihhrpid jhhrpid khhrpid lhhrpid mhhrpid nhhrpid. * (1.3) Load macro to write a program to rename variables, dropping first * character (wave identifier) of variable name. ID's are not renamed. define renwave (!pos=!cmdend). get file=!1. n of cases 1. set printback=off /results=no. flip. set printback=on /results=yes. compute x=1. match files file=*/last=last/by x. string out (a60). do if $casenum=1. write outfile=renprog/"rename variables". end if. /* exclude ids from renaming */ do if (char.index(lower(case_lbl),'waveid')>0) or (char.index(lower(case_lbl),'hhrhid')>0) or (char.index(lower(case_lbl),'hhraid')>0) or (char.index(lower(case_lbl),'hhrpid')>0) . compute out=concat(" (",case_lbl," = ",lower(case_lbl),")"). else. compute out=concat(" (",lower(case_lbl)," = ",char.substr(lower(case_lbl),2),")"). end if. write outfile=renprog/out. do if (last). write outfile=renprog/" .". end if. exe. !enddefine. /* end of macro */ /* ************************************************************************* */ /* Section 2: create "long" balanced responding person longitudinal file */ /* ************************************************************************* */ * (2.1) Rename each wave: run macro "renwave" and then include the generated rename program. * command file. Keep only those records from balanced master file. renwave w1c . get file=w1c. include file=renprog. sort cases by xwaveid. match files file=balanced/in=inm1/file=*/by xwaveid. select if (inm1). save outfile=w1l. renwave w2c . get file=w2c. include file=renprog. sort cases by xwaveid. match files file=balanced/in=inm2/file=*/by xwaveid. select if (inm2). save outfile=w2l. renwave w3c . get file=w3c. include file=renprog. sort cases by xwaveid. match files file=balanced/in=inm3/file=*/by xwaveid. select if (inm3). save outfile=w3l. renwave w4c . get file=w4c. include file=renprog. sort cases by xwaveid. match files file=balanced/in=inm4/file=*/by xwaveid. select if (inm4). save outfile=w4l. renwave w5c . get file=w5c. include file=renprog. sort cases by xwaveid. match files file=balanced/in=inm5/file=*/by xwaveid. select if (inm5). save outfile=w5l. renwave w6c . get file=w6c. include file=renprog. sort cases by xwaveid. match files file=balanced/in=inm6/file=*/by xwaveid. select if (inm6). save outfile=w6l. renwave w7c . get file=w7c. include file=renprog. sort cases by xwaveid. match files file=balanced/in=inm7/file=*/by xwaveid. select if (inm7). save outfile=w7l. renwave w8c . get file=w8c. include file=renprog. sort cases by xwaveid. match files file=balanced/in=inm8/file=*/by xwaveid. select if (inm8). save outfile=w8l. renwave w9c . get file=w9c. include file=renprog. sort cases by xwaveid. match files file=balanced/in=inm9/file=*/by xwaveid. select if (inm9). save outfile=w9l. renwave w10c . get file=w10c. include file=renprog. sort cases by xwaveid. match files file=balanced/in=inm10/file=*/by xwaveid. select if (inm10). save outfile=w10l. renwave w11c . get file=w11c. include file=renprog. sort cases by xwaveid. match files file=balanced/in=inm11/file=*/by xwaveid. select if (inm11). save outfile=w11l. renwave w12c . get file=w12c. include file=renprog. sort cases by xwaveid. match files file=balanced/in=inm12/file=*/by xwaveid. select if (inm12). save outfile=w12l. renwave w13c . get file=w13c. include file=renprog. sort cases by xwaveid. match files file=balanced/in=inm13/file=*/by xwaveid. select if (inm13). save outfile=w13l. renwave w14c . get file=w14c. include file=renprog. sort cases by xwaveid. match files file=balanced/in=inm14/file=*/by xwaveid. select if (inm14). save outfile=w14l. * (2.3) Add datasets together to create the balanced long longitudinal. * responding person file. Add a year variable. Balanced panel long. add files file=w1l/in=w1/file=w2l/in=w2/file=w3l/in=w3/file=w4l/in=w4/file=w5l/in=w5/file=w6l/in=w6 /file=w7l/in=w7/file=w8l/in=w8/file=w9l/in=w9 /file=w10l/in=w10/file=w11l/in=w11/file=w12l/in=w12/file=w13l/in=w13/file=w14l/in=w14. if (w1=1) year = 2001. if (w2=1) year = 2002. if (w3=1) year = 2003. if (w4=1) year = 2004. if (w5=1) year = 2005. if (w6=1) year = 2006. if (w7=1) year = 2007. if (w8=1) year = 2008. if (w9=1) year = 2009. if (w10=1) year = 2010. if (w11=1) year = 2011. if (w12=1) year = 2012. if (w13=1) year = 2013. if (w14=1) year = 2014. save outfile=w1w14long. freq vars=year. /*(2.4) Supplementary programme to create longitudinal weights variables for Responding and Enumerated Persons specifically to be used in a balanced file of all waves. */ get file=w1w14long/drop=lnwtrp lnwte. sort cases by xwaveid. match files file=*/table=w14c/rename=( nlnwtrp nlnwte=lnwtrp lnwte)/keep=xwaveid to year lnwtrp lnwte /* !!!UPDT rename first 2 vars */ /by xwaveid. means vars=lnwtrp by year. save outfile=w1w14long_1.