* Syntax creates AFCARS Foster Care Annual File for 2009 . * from converted submissions 2009 A and 2009 B. GET FILE='c:\composite\xxx10a.sav'. compute priorbeg=yrmoda(2009,09,30). compute periodbeg=yrmoda(2009,10,01). compute periodend=yrmoda(2010,09,30). compute afterend=yrmoda(2010,10,01). compute entryday=YRMODA(latremyr,latremmo,latremda). compute exitday=YRMODA(dodfcyr,dodfcmo,dodfcda). compute dob=yrmoda(dobyr,dobmo,dobda). compute key=1. formats key (f1.0). exe. save outfile='c:\composite\tempxxx10a.sav'. GET FILE='c:\composite\xxx10b.sav'. compute priorbeg=yrmoda(2009,09,30). compute periodbeg=yrmoda(2009,10,01). compute periodend=yrmoda(2010,09,30). compute afterend=yrmoda(2010,10,01). compute entryday=YRMODA(latremyr,latremmo,latremda). compute exitday=YRMODA(dodfcyr,dodfcmo,dodfcda). compute dob=yrmoda(dobyr,dobmo,dobda). compute key=2. formats key (f1.0). exe. save outfile= 'c:\composite\tempxxx10b.sav'. get file= 'c:\composite\tempxxx10a.sav'. ADD FILES /FILE=* /FILE='c:\composite\tempxxx10b.sav'. exe. /** Identify Duplicate Cases - Using Record Number and FIPS. SORT CASES BY recnumbr(A) fipscode(A) key(A) . MATCH FILES /FILE = * /BY recnumbr fipscode /FIRST = PrimaryFirst /LAST = PrimaryLast. DO IF (PrimaryFirst). COMPUTE MatchSequence = 1 - PrimaryLast. ELSE. COMPUTE MatchSequence = MatchSequence + 1. END IF. LEAVE MatchSequence. FORMAT MatchSequence (f7). COMPUTE InDupGrp = MatchSequence > 0. SORT CASES InDupGrp(D). MATCH FILES /FILE = * /DROP = PrimaryFirst InDupGrp. VARIABLE LABELS PrimaryLast 'Indicator of each last matching case as Primary' MatchSequence 'Sequential count of matching cases' . VALUE LABELS PrimaryLast 0 'Duplicate Case' 1 'Primary Case'. VARIABLE LEVEL PrimaryLast (ORDINAL) /MatchSequence (SCALE). FREQUENCIES VARIABLES = PrimaryLast MatchSequence . EXECUTE. filter off. use all. select if(primarylast=1). exe. /** Identify Duplicate Cases - Using Record Number and DOB. SORT CASES BY recnumbr(A) dob(A) key(A) . MATCH FILES /FILE = * /BY recnumbr dob /DROP = PrimaryLast MatchSequence /FIRST = PrimaryFirst /LAST = PrimaryLast. DO IF (PrimaryFirst). COMPUTE MatchSequence = 1 - PrimaryLast. ELSE. COMPUTE MatchSequence = MatchSequence + 1. END IF. LEAVE MatchSequence. FORMAT MatchSequence (f7). COMPUTE InDupGrp = MatchSequence > 0. SORT CASES InDupGrp(D). MATCH FILES /FILE = * /DROP = PrimaryFirst InDupGrp. VARIABLE LABELS PrimaryLast 'Indicator of each last matching case as Primary' MatchSequence 'Sequential count of matching cases' . VALUE LABELS PrimaryLast 0 'Duplicate Case' 1 'Primary Case'. VARIABLE LEVEL PrimaryLast (ORDINAL) /MatchSequence (SCALE). FREQUENCIES VARIABLES = PrimaryLast MatchSequence . EXECUTE. filter off. use all. select if (primarylast=1). exe. COMPUTE NStatus=1. exe. IF (MISSING(entryday) and (exitday > 0)) NStatus=2. exe. value labels NStatus 1'NExists' 2'Missing N'. exe. freq NStatus. *review output and determine whether there are a large proportion of cases with missing entry dates. compute flag=0. IF ((MISSING(latremyr) and (YRMODA(dodfcyr,dodfcmo,dodfcda)) <= periodend and (yrmoda(dodfcyr,dodfcmo,dodfcda)) >= periodbeg or (yrmoda(latremyr,latremmo,latremda)) <= periodend and (missing(dodfcyr)) or (yrmoda(dodfcyr,dodfcmo,dodfcda)) >= periodbeg)) flag=1. freq flag. *review output and determine whether there are a large proportion of cases where flag=0; if so, this means that there are cases that were *outside of the reporting period. sel if flag=1. exe. SAVE OUTFILE='c:\composite\xxx10ab.sav' /DROP=flag NStatus priorbeg periodbeg periodend afterend entryday exitday dob key PrimaryLast MatchSequence.