  The Sloan Digital Sky Survey (SDSS) currently provides by far the largest
homogeneous sample of intermediate signal-to-noise ratio (S/N) optical spectra
of galaxies and quasars. The fully automated SDSS spectroscopic reduction
pipeline has provided spectra of unprecedented quality that cover the
wavelength range 3800-9200A. However, in common with spectra from virtually all
multi-object surveys employing fibres, there remain significant systematic
residuals in many of the spectra due to the incomplete subtraction of the
strong OH sky emission lines longward of 6700A. The S/N over substantial
wavelength regions in many spectra is reduced by more than a factor of 2 over
that expected from counting statistics. We present a method to automatically
remove the sky residual signal, using a principal component analysis (PCA)
which takes advantage of the correlation in the form of the sky subtraction
residuals present in each spectrum. Application of the method results in
spectra with essentially no evidence for degradation due to the incomplete
subtraction of OH emission features. A dramatic improvement in the quality of a
substantial number of spectra, particularly those of faint objects such as the
bulk of the high-redshift quasars, is achieved. We make available IDL code and
documentation to implement the sky residual subtraction scheme on SDSS spectra
included in the public data releases. We illustrate the power of the
sky-residual subtraction scheme using samples of SDSS galaxy and quasar
spectra, presenting tests involving the near-infrared CaII triplet absorption,
metal absorption line features in damped Lyman-alpha systems and composite
spectra of high-redshift quasars.
