The density $({N}_{A})$ and energy level $({E}_{A})$ of an acceptor in a $p$-type wide-band-gap semiconductor (e.g., SiC, GaN, and diamond) are determined by a least-squares fit of the charge neutrality equation to the temperature dependence of the hole concentration $p(T)$ using the Fermi-Dirac distribution function for acceptors that does not consider the influence of the excited states of the acceptor. The ${N}_{A}$ obtained this way is, however, much higher than the concentration of acceptor atoms determined by secondary ion mass spectroscopy. Because ${E}_{A}$ is far from the valence-band maximum $({E}_{V})$ and the Fermi level is between ${E}_{A}$ and ${E}_{V}$, the influence of the excited states of the acceptor on $p(T)$ should not be ignored. A distribution function including the influence of excited states, which is derived from the viewpoint of the microcanonical ensemble, not the grand canonical ensemble, leads to reliable ${N}_{A}$ and ${E}_{A}$. The situation in $n$-type Te-doped ${\mathrm{Al}}_{0.6}{\mathrm{Ga}}_{0.4}\mathrm{Sb}$ is the same, because the Te donor level is far from the conduction-band minimum for large Al mole fraction. Finally, the excited states of a substitutional dopant with a deep energy level are found to enhance the ionization of the dopant, even though they were expected to suppress the ionization because they acted as a trap according to the distribution function derived from the viewpoint of the grand canonical ensemble.