Dear All, Suppose that I have a dataset
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input long id str1 typrep str3 indu float(roa roe bsdt)
1 "A" "J66" .008948 .294976 17622
1 "A" "J66"       .       . 17713
1 "B" "J66"  .00971 .297848 17713
1 "A" "J66" .010469 .306175 17805
1 "B" "J66"       .       . 17805
1 "A" "J66" .001485 .041761 17897
1 "A" "J66" .001572 .047049 17987
2 "A" "K70" .069677 .203744 17622
2 "B" "K70" .042736 .090677 17622
2 "A" "K70"       .       . 17713
2 "B" "K70" .088329 .181697 17713
2 "A" "K70" .054147 .176788 17805
2 "B" "K70" .075659 .152047 17805
end
format %td bsdt
There are twp kinds of reports, `typrep'=A,B. I wish to keep only one type of report A or B for each `id' and `bsdt'.
  1. If `roa' is available for both A and B, choose A.
  2. If `roa' is missing for B, keep A.
  3. if `roa' is missing for A, Keep A.
Any suggestions? Thanks.