We present a linear stability analysis of an oscillating granular layer, treating it as an isothermal incompressible fluid with zero surface tension, which undergoes periodic collisions with and separations from an oscillating plate. Because the viscosity of the granular layer is unknown, we use the experimental value of the critical acceleration for the transition from a flat to patterned layer as input for the theory, and use the analysis to calculate the granular viscosity and the wavelength of the most unstable mode. The wavelength compares favorably with the experimental pattern wavelength. Further, we find that the wavelengths are controlled by the viscosity of the granular layer. [S1063-651X(99)11112-7].