We theoretically formulate and experimentally demonstrate an analytical formalism for the design of printed circuit board (PCB) metagratings (MGs) exercising individual control over the amplitude and phase of numerous diffracted modes, in both reflection and transmission. Lately, these periodic arrangements of subwavelength polarizable particles (meta-atoms) were shown to deflect an incoming plane wave to prescribed angles with very high efficiencies, despite their sparsity with respect to conventional metasurfaces. Nonetheless, most reported MGs were designed based on full-wave optimization of the meta-atoms, with the scarce analytical schemes leading directly to realizable devices were restricted to single-layer reflecting structures, controlling only the partition of power. In this paper, we present an analytical model for plane-wave interaction with a general multilayered multielement MG, composed of an arbitrary number of meta-atoms distributed across an arbitrary number of layers in a given stratified media configuration. For a desired (forward and backward) diffraction pattern, we formulate suitable constraints, identify the required number of degrees of freedom, and correspondingly set them to yield a detailed MG configuration implementing the prescribed functionality; no full-wave optimization is involved. To verify and demonstrate the versatility of this systematic approach, fabrication-ready multilayer PCB MGs for perfect anomalous refraction and non-local focusing are synthesized, fabricated, and experimentally characterized, for the first time to the best of our knowledge, indicating very good correspondence with theoretical predictions. This appealing semianalytical methodology is expected to accelerate the development of MGs and extend the relevant range of applications, yielding practical MG designs on demand for arbitrary beam manipulation.