Hi all, I have to admit my do-loop skill is too weak. I need to sort out the first and last months when shipping was made for each year within a year. As shown below, the columns of startmon and endmon are my objective variables I want. OrderID mons mon1 mon2 mon3 mon4 mon5 mon6 mon7 mon8 mon9 mon10 mon11 mon12 year startmon endmon 1 4 1 1 1 1 0 0 0 0 0 0 0 0 2012 1 4 2 11 0 1 1 1 1 1 1 1 1 1 1 1 2012 2 12 3 12 1 1 1 1 1 1 1 1 1 1 1 1 2012 1 12 4 1 1 0 0 0 0 0 0 0 0 0 0 0 2012 1 1 5 6 0 0 0 1 1 1 1 1 1 0 0 0 2012 4 9 Also, for the orders across years as below, I need to abstract a separate file with startmon, endmon, startyr and endyr. Original data: OrderID mons mon1 mon2 mon3 mon4 mon5 mon6 mon7 mon8 mon9 mon10 mon11 mon12 year 1 12 12 1 1 1 1 1 1 1 1 1 1 1 2011 3 3 0 0 0 0 0 0 0 0 0 1 1 1 2011 4 11 0 1 1 1 1 1 1 1 1 1 1 1 2011 1 4 1 1 1 1 0 0 0 0 0 0 0 0 2012 2 11 0 1 1 1 1 1 1 1 1 1 1 1 2012 3 12 1 1 1 1 1 1 1 1 1 1 1 1 2012 4 1 1 0 0 0 0 0 0 0 0 0 0 0 2012 5 6 0 0 0 1 1 1 1 1 1 0 0 0 2012 1 12 1 1 1 1 1 1 1 1 1 1 1 1 2013 2 10 1 1 1 1 1 1 1 1 1 1 0 0 2013 3 2 1 1 0 0 0 0 0 0 0 0 0 0 2013 5 12 1 1 1 1 1 1 1 1 1 1 1 1 2013 Objective data: OrderID startmon endmon staryr endyr 1 1 4 2011 2012 2 2 10 2012 2013 3 10 2 2011 2013 4 2 1 2011 2012 5 4 12 2012 2013 Your ideas are greatly appreciated! Lizi
... View more