title: Report using data _Null_
body: <p>I'm looking for report using SAS data step :</p>
  
  <p>I have a data set:</p>
  
  <pre><code>Name Company Date
  X    A       199802
  X    A       199705
  X    D       199901 
  y    B       200405
  y    F       200309
  Z    C       200503
  Z    C       200408
  Z    C       200404
  Z    C       200309
  Z    C       200210
  Z    M       200109
  W    G       200010
  </code></pre>
  
  <p>Report I'm looking for:</p>
  
  <pre><code>Name Company From     To
  X    A      1997/05   1998/02
       D      1998/02   1999/01
  Y    B      2003/09   2004/05
       F      2003/09   2003/09
  Z    C      2002/10   2005/03
       M      2001/09   2001/09
  W    G      2000/10   2000/10
  </code></pre>
  
  <p>THANK you,</p>
  
  <p>Tried using proc print but it is not accurate. So looking for a data <em>null</em> solution.</p>
  
  <pre><code>data  _null_;
  set salesdata;
  by name company date;
  
  array x(*) from;
  From=lag(date);
   if first.name  then count=1;
  do i=count to dim(x);
  x(i)=.;
  end;
  count+1;
  If first.company then do;
  from_date1=date;
  
  end;
  if last.company then To_date=date;
  if from_date1 ="" and to_date="" then delete;
   run;
  </code></pre>