My table contains 8 variables: ID, VAR1-VAR7.
VAR5 is a character variable and the others are numerical.
Each ID have several records. I want to have only one record for each ID in the following way:
VAR1 = MIN(VAR1)
MIN(VAR3) should be assigned to a new variable, lets say AVAR3=MIN(VAR3).
If VAR4=1 or VAR4=2 in ANY of ID:s records, then I should find the MAX(VAR3) among those. That value should be assigned to a new variable, lets say BVAR3=MAX(VAR3) and VAR2, VAR4, VAR6 and VAR7 should be kept from the same record.
If VAR4~=1 and VAR4~=2 in ALL of ID:s records, then I should find the MAX(VAR2) among those. The assignment to BVAR3 then should be BVAR3=VAR3 from that record and VAR2, VAR4, VAR6 and VAR7 should be kept from the same record.
If ANY of ID:s VAR5='A' or 'B' then I would like to assign the value 1 to the new numerical variable AVAR5, otherwise AVAR5 should have the value 0.
Thanks for any help, with this rather complicated problem.