A novel technology based on stacked intelligent metasurfaces (SIM) has recently emerged. This platform involves cascading multiple metasurfaces, each acting as a digitally programmable physical layer within a diffractive neural network. SIM enable the implementation of signal-processing transformations directly in the electromagnetic wave domain, eliminating the need for expensive, high-precision, and power-intensive digital platforms. However, existing studies employing SIM in wireless communication applications rely solely on nearly passive structures that control only the phase of the meta-atoms in each layer. In this study, we propose a SIM-aided downlink multiuser transmission scheme, where the SIM at the base station (BS) end is designed by combining nearly passive layers with phase-only reconfiguration capabilities and active layers integrated with amplifier chips to enable amplitude control. Our optimal design aims at maximizing the sum rate for the best group of users by jointly optimizing the transmit power allocation at the BS and the wave-based beamforming at the SIM. In addition to the standard sum-power constraint at the BS, our optimization framework includes two additional constraints: (i) a per-stream power preserving constraint to prevent propagation losses across the SIM, and (ii) an amplitude constraint to account for power limitations for each active layer. To further reduce the complexity of the optimal beamforming solution, we explore a simple yet suboptimal zero-forcing (ZF) beamforming design, where the wavebased transformation implemented by the SIM is selected to eliminate interference among user streams. Finally, extensive Monte Carlo simulations demonstrate that incorporating both nearly passive and active layers within the SIM significantly enhances capacity compared to previously reported phase-only coding SIM.