LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (September 2003, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 3 Sep 2003 14:33:53 +0200
Reply-To:     Leslie Fisher <lfisher@METHOD-CONSULT.DE>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Leslie Fisher <lfisher@METHOD-CONSULT.DE>
Subject:      Interleaved merging/combining two datasets
Content-Type: text/plain; charset="us-ascii"

Hi, I have problems merging two datasets (sorted by the time variables): Dataset A Dataset B LNAME FNAME DATEFROM DATETO YESNO LNAME FNAME DATEB VAR1 VAR2 VA33.... Smith Jay 11.11.03 25.11.03 0 Smith Jay 11.11.03 values............................ Presley Elvis 13.12.02 27.12.02 1 Presley Elvis 31.12.02 values............................

Presley Elvis 11.09.03 values............................

Presley Elvis 27.12.03 values............................ etc. What has to be done basically is a merge by NNAME, FNAME, and DATAFROM/TO(dataset A) and DATEB (dataset B). For every YESNO=0, the logic is: Pick and merge by LNAME+FNAME+DATEFROM/DATEB only the oldest dataline of B to A of that individual, and for every YESNO=1, the logic is: Pick and merge by LNAME+NMAE+DATETO/DATEB only the latest dataline of B to A of that individual. The result should be: Dataset C

LNAME FNAME DATEFROM DATETO YESNO DATEB VAR1 VAR2 VA33.... Smith Jay 11.11.03 25.11.03 0 11.11.03 values............................. Presley Elvis 13.12.02 27.12.02 1 27.12.03 values............................ etc. Every individual from dataset A has definitively only one "1" or "0" in YESNO. In the case of YESNO=0 the values of DATEFROM (dataset A) should always correspond to the single DATEB (dataset B) value. In the case of YESNO=1 the max value of DATETO (dataset A) should always correspond to the last/latest DATEB (dataset B) value. I've tried several SQL apporaches, but got stuck. Please help, Thanks a lot & Good luck! Leslie


Back to: Top of message | Previous page | Main SAS-L page