As @Astounding pointed correctly, you'd have to use procedure (as in the description of you homework 😉). Although, the data step is incorrect anyway: You don't retain the value of OldestMother and OlderstFather to next rows when processing. So when if statements are evaluated, you're just comparing the values within the same row, you're not considering previous values of dmage, dfage (I'd suggest to play around with this a bit and see the numbers yourself). There is no data structure provided in your question, so I'm only guessing the row consists of a couple, where in row you have age of mother and father. When you use if dfage < 99, you will exclude rows, and loose information on dmage
... View more