In my data, each subject has been observed 1-10 times. The dates of these observations are in separate columns: date1, date2... date10. How can I write a function that will choose the latest of these dates within a defined range? If I simply wanted the latest overall, it would just be a maximum function, but what if I want the latest date within 2009, for example? Can anybody see a way to get this?