title: mimic window function in sas to group rows and calculate the max continuous membership
body: <p>I have a table like this showing the id of a member, the beginning and end date of their membership, the days of their membership and the gap between their last membership and current membership period.</p>
  <ul>
  <li>for example, member 11101 started their membership on 3/1/95 and paused their membership on 11/01/97. they renewed their membership on 6/1/97 without a gap. the total days of this span is 822+153=975 days</li>
  <li>he terminated his membership on 11/1/97 and restarted it on 11/10/04. the gap between these two membership are 11/10/04-11/01/97=2565 days</li>
  </ul>
  <p>Im trying to find out the longest spans of a certain member's continuous membership, which is 2160 in this case. I think a window function lag/lead is necessary in SQL. however window function is not supported in sql. how can group these periods based on gap days and calculate the max spans?</p>
  <p>thank you for the help!
  <a href="https://i.stack.imgur.com/wvG3r.jpg" rel="nofollow noreferrer">enter image description here</a></p>