SAS FAQ (UCLA) The above link addresses the question, "How can I create an enumeration variable by groups?" The last paragraph states that it is not difficult to create an enumeration variable by groups with multiple layers, but I am having problems doing so. My data is organized by an ID variable, a time variable (year), and then an intra-time variable (quarter). But the data contains gaps. For example, it may be like the following: ID Year Quarter 1 2000 1 1 2000 2 1 2004 1 I want to count how many consecutive quarterly observations I have. I tried following the sample code in the link above: data two1; set two; count + 1; by id year quarter; if first.id or first.year or first.quarter then count = 1; run; But that did not do it for me. I think a problem I have is that there could be a consecutive string from the fourth quarter of year t - 1 to the first quarter of year t. My output was wrong regardless.
... View more