Selection on Observed and Unobserved Variables in Observational and Randomized Analyses