Electronic sputtering of solid nitrogen and oxygen by keV hydrogen ions has been studied at two low-temperature setups. The yield of the sputtered particles has been determined in the energy regime 4-10 keV for H+, H-2+ and H-3+ ions. The yield for oxygen is more than a factor of two larger than that for nitrogen. The energy distributions of the sputtered N2 and O2 molecules were measured for hydrogen ions in this energy regime as well. The yields from both solids turn out to depend on the sum of the stopping power of all atoms in the ion. The yield increases as a quadratic function of the stopping power for oxygen, but slightly slower for nitrogen. The energy distributions do not exhibit strong features, but are similar to those published earlier for electron sputtering.