The -collapse- command (https://www.stata.com/manuals/dcollapse.pdf) has a -percent- statistic that (according to the documentation) shows the
percentage of nonmissing observations
Here is an example with a by() option:

Code:
. input a b

             a          b
  1. 1 1
  2. 1 1
  3. 1 2
  4. . 2
  5. end

. collapse (percent) a,by(b)

. list

     +--------------+
     | b          a |
     |--------------|
  1. | 1   66.66667 |
  2. | 2   33.33333 |
     +--------------+
I am surprised by this result. I expected the collapsed values of a to be 100 and 50. Are not all the values of a non-missing for b==1 and half the values non-missing for b==2? Where does the 3 in the denominator of the -collapse- calculation come from? Is there a way to get the result I was expecting?