Selection bias remains a more difficult bias to understand than confounding or measurement error. Past definitions have not always been illuminating and a simple method (such as the change-in-estimate method for confounding) has not been available to determine its presence and magnitude in the study sample. A better understanding of the nature of the bias has led to the definition of endogenous selection bias. It is the result of conditioning on a collider variable, itself caused by two other variables; the latter variables become spuriously associated. Conditioning on a variable in the analysis that is a collider or on an indicator of sample selection has the same effect. Note that selection bias is possible even in the absence of a collider, but in the presence of endogenous selection bias, the concern is whether it is possible to identify a causal effect in the sample. Conditions have been outlined to determine that. However, even if conditions are met to identify a causal effect in the study sample, its generalization to a defined target population is not a given.We discuss the concept of endogeneity and the sources of endogenous selection bias in observational studies. We then briefly address the terms generalizability, target population (or alternative formulations) and transportability. We outline the explicit conditions to identify causal effects in studies affected by selection bias: they involve exchangeability between exposed and unexposed and exchangeability between sampled and unsampled. We briefly describe methods to generalize estimated causal effects to the target population. The latter usually require data from the target population. Finally we discuss sensitivity analyses; some are limited to providing an indication of the presence and direction of the bias and others can provide corrected estimates with user-supplied selection bias parameters.