It is generally difficult to quantify the amounts of light elements in materials because of their low X-ray-scattering power, as this means that they cannot be easily estimated via X-ray analyses. Meanwhile, the recently reported layered superconductor, Sc$_{20}$C$_{8-x}$B$_x$C$_{20}$, requires a small amount of boron, which is a light element, for its structural stability. In this context, here, we quantitatively evaluate the optimal $x$ value using both the experimental and computational approaches. Using the high-pressure synthesis approach that can maintain the starting composition even after sintering, we obtain the Sc$_{20}$(C,B)$_{8}$C$_{20}$ phase by the reaction of the previously reported Sc$_{15}$C$_{19}$ and B (Sc$_{15}$B$_y$C$_{19}$). Our experiments demonstrate that an increase in $y$ values promotes the phase formation of the Sc$_{20}$(C,B)$_{8}$C$_{20}$ structure; however, there appears to be an upper limit to the nominal $y$ value to form this phase. The maximum $T_mathrm{c}$ $(=7.6text{ K})$ is found to correspond with the actual $x$ value of $x sim 5$ under the assumption that the sample with the same $T_mathrm{c}$ as the reported value $(=7.7text{ K})$ possesses the optimal $x$ amount. Moreover, we construct the energy convex hull diagram by calculating the formation enthalpy based on first principles. Our computational results indicate that the composition of Sc$_{20}$C$_4$B$_4$C$_{20}$ $(x=4)$ is the most thermodynamically stable, which is reasonably consistent with the experimentally obtained value.