I am writing a SAS program that has too many IF THEN statements and it is getting overwhelmingly complicated. I am working with ages and placement of number of kids into "age buckets". Can you please take a look and try to figure out how to help with this (maybe with an array or a loop?).

Variables:

Ager (age at interview time - coded: 15-44)

Howmany (how many kids do you have - coded: 1-9)

Fathers_age_kid1

Fathers_age_kid2

Fathers_age_kid3

Fathers_age_kid4

Fathers_age_kid5

Fathers_age_kid6

Fathers_age_kid7

Fathers_age_kid8

Fathers_age_kid9

Need data to output into:

Bucket1 (did father have kid between 15-19? If yes, drop here)

Bucket2 (did father have kid between 20-24? If yes, drop here - and if there is a number in the previous bucket, add 1 to the previous number)

Bucket3 (did father have kid between 25-29? If yes, drop here - and if there is a number in the previous buckets, add 1 to the previous number)

Bucket4 (did father have kid between 30-34? If yes, drop here - and if there is a number in the previous buckets, add 1 to the previous number)

Bucket5 (did father have kid between 35-39? If yes, drop here - and if there is a number in the previous buckets, add 1 to the previous number)

Bucket6 (did father have kid between 40-44? If yes, drop here - and if there is a number in the previous buckets, add 1 to the previous number)

So, each bucket with ascending age groups will keep a count of how many kids at what age. There are missing values involved in each father's age of kid(s) and that is throwing my program off. Plus, there are multiple births (twins, triplets, quads, etc.) or kids born a year or two after the previous one which will not increment the same bucket N.

Thanks very much for your help with this.