Hi Robert, Yes, both method should achieve your desired results. The main reason why Tom has suggested the transpose method is that the array method requires you to know, a priori, the maximum of groups for any given day (so as to set the array dimensions). You could, for instance, not care to add additionnal missing columns to your dataset and simply set a value "high enough" that it will never be reached but that depends on your requirements and what further processing you may want to do on this data. The transpose method has the advantage of creating variables only for each distinct ID (as defined by the variables in the ID statement of the proc transpose, not the ID variable in your dataset). So for instance, if you used this for 2 distinct datasets (lets say year 2011 and year 2012) and in year 2011, the maximum number of in/out pair for an ID is 30 and in 2012, it is instead 42, the transpose method on the 2011 dataset will provide you with a dataset with 61 columns and 2012 with 85 columns. On the other hand, if you used the array method and set array in (50); array out (50) ; "just to be safe" as you didn't know, a priori, how many distinct events occured on any given ID, then both 2011 and 2012 data would yield a dataset with 101 columns with the array method. You would effectively have the last 40 (resp. 16) columns missing for all records in the 2011 (resp. 2012) resulting datasets. So really, the approach to use depends on your task requirements and your a priori knowledge of your data. As to go back to the cnt=cnt-.1 and cnt=cnt+.1, looking back at the data you have provided, I realize it does not achieve what I wanted as your cnt variable is not a counter of sequential events for an ID but rather a counter of sequential events for an ID FLAG pair. The underlying logic would've been something like this: 101 IN 04Sep1989:7:30 1 101 IN 04Sep1989:13:45 2 101 IN 21SEP1989:17:55 3 101 OUT 05SEP1989:7:15 1 101 OUT 22SEP1989:06:00 2 101 OUT 23SEP1989:06:00 12 101 IN 24SEP1989:06:00 15 If you sort this by id time, you get 101 IN 04Sep1989:7:30 1 101 IN 04Sep1989:13:45 2 101 OUT 05SEP1989:7:15 1 101 IN 21SEP1989:17:55 3 101 OUT 22SEP1989:06:00 2 101 OUT 23SEP1989:06:00 12 101 IN 24SEP1989:06:00 15 Now imagine that you had a different "counter" that represents the sequence of events within a given ID as follow NEWCNT 101 IN 04Sep1989:7:30 1 1 101 IN 04Sep1989:13:45 2 2 101 OUT 05SEP1989:7:15 1 3 101 IN 21SEP1989:17:55 3 4 101 OUT 22SEP1989:06:00 2 5 101 OUT 23SEP1989:06:00 12 6 101 IN 24SEP1989:06:00 15 7 The logic of the +.1 -.1 was that the created records with a missing date would allow you to sort by id newcnt to achieve the appropriate sorting by time within an ID even though you had a bunch of missing time. 101 IN 04Sep1989:7:30 1 1 101 OUT . . 1.1 101 IN 04Sep1989:13:45 2 2 101 OUT 05SEP1989:7:15 1 3 101 IN 21SEP1989:17:55 3 4 101 OUT 22SEP1989:06:00 2 5 101 IN . . 5.9 101 OUT 23SEP1989:06:00 12 6 101 IN 24SEP1989:06:00 15 7 101 OUT . . 7.1 Due to the way my data step is built for middle2, the IN records with missing time are output after their respective OUT records so the way to rebuild the sequence of events with missing values would be through something similar. Again though, it will not work as intended after review since your CNT variable is not built the way I had in mind when I wrote the code. Nonetheless, it is irrelevant to the proc transpose. It is merely a conceptual tool if you wanted to have a full sequence of events vertically rather than horizontally. Vincent
... View more