Explaining group-level outcomes from individual-level predictors requires aggregating the individual-level scores to the group level and correcting the group-level estimates for measurement errors in the aggregated scores. However, for discrete variables it is not clear how to perform the aggregation and correction. It is shown how stepwise latent class analysis can be used to do this. First, a latent class model is estimated in which the scores on a discrete individual-level predictor are used to construct group-level latent classes. Second, this latent class model is used to aggregate the individual-level predictor by assigning the groups to the latent classes. Third, a group-level analysis is performed in which the aggregated measures are related to the remaining group-level variables while correcting for the measurement error in the class assignments. This stepwise approach is introduced in a multilevel mediation model with a single individual-level mediator, and compared to existing methods in a simulation study. We also show how a mediation model with multiple group-level latent variables can be used with multiple individual-level mediators and this model is applied to explain team productivity (group level) as a function of job control (individual level), job satisfaction (individual level), and enriched job design (group level).