title: How to calculate "midpoint date" by group in Stata?
body: <p>I have a dataset with two variables: <code>journalistName</code>, <code>articleDate</code></p>
  
  <p>For each journalist (group),  I want to create a variable that chronologically categorizes the articles into <code>1</code> for "first half" and <code>2</code> for "second half".</p>
  
  <p>For example, if a journalist wrote 4 articles, I want first two articles categorized as <code>1</code>. </p>
  
  <p>If he wrote 5 articles, I want first three articles categorized as <code>1</code>. </p>
  
  <p>One possibility I thought of is to calculate the midpoint date and then use if condition (<code>gen cat1 = 1 if midpoint &gt; startdate</code>) but I dont know how to generate such midpoint in Stata.</p>