Code:
     +--------------------------------------------------------+
     | year             id   date_in~e   date_fo~d   date_i~d |
     |--------------------------------------------------------|
  1. | 1990   ARP008791179   24mar2009   01jan1940          . |
  2. | 1990   ARP008791179           .           .          . |
  3. | 1990   ARP460221020           .   01jan1882          . |
  4. | 1990   ARP460221020           .           .          . |
  5. | 1990   ARP689251337           .   10jul1931          . |
     +--------------------------------------------------------+
I want to drop duplicates based on year and id. Although year and ids are duplicated, date_* variables are different in some cases. I want to keep ids by year that have more date_* info. For example, in observations 1 and 2 ids are the same but observation 1 has more date_* info.

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input double year str40 id long(date_inactive date_founded date_incorporated)
1990 "ARP008791179" 17980  -7305     .
1990 "ARP008791179"     .      .     .
1990 "ARP460221020"     . -28488     .
1990 "ARP460221020"     .      .     .
1990 "ARP689251337"     . -10402     .
1990 "ARP689251337"     .      .     .
1990 "ARPERE010103" 21326      .     .
1990 "ARPERE010103" 21326  -5113 -4428
1990 "AT0000609607"     .      .     .
1990 "AT0000609607"     . -33158     .
1991 "ARP008791179"     .      .     .
1991 "ARP008791179" 17980  -7305     .
1991 "ARP460221020"     .      .     .
1991 "ARP460221020"     . -28488     .
1991 "ARP646041201" 18401      .     .
1991 "ARP646041201" 18401      .     .
1991 "ARP689251337"     .      .     .
1991 "ARP689251337"     . -10402     .
1991 "ARP9028N1016"     .  11151 11151
1991 "ARP9028N1016"     .      .     .
1991 "ARP903251048"     .      .     .
1991 "ARP903251048" 20602      . 11269
1991 "ARP9897X1319"     .      .  6362
1991 "ARP9897X1319"     .      .     .
end
format %d date_inactive
format %d date_founded
format %d date_incorporated