This paper presents a coalitional game for value sharing in energy communities (ECs). It is proved that the game is super-additive, and the grand coalition effectively increases the global payoff. It is also proved that the model is balanced and thus, it has a nonempty core. This means there always exists at least one value sharing mechanism that makes the grand coalition stable. Therefore, prosumers will always achieve lower bills if they join to form larger ECs. A counterexample is presented to demonstrate that the game is not convex and value sharing based on Shapley values does not necessarily ensure the stability of the coalition. To find a stabilizing value sharing mechanism that belongs to the core of the game, the worst-case excess minimization concept is applied. In this concept, however, size of the optimization problem increases exponentially with respect to the number of members in EC. To make the problem computationally tractable, the idea of clustering members based on their generation/load profiles and considering the same profile and share for members in the same cluster is proposed here. K-means algorithm is used for clustering prosumers' profiles. This way, the problem would have several redundant constraints that can be removed. The redundant constraints are identified and removed via the generalized Llewellyn's rules. Finally, value sharing in an apartment building in the southern part of Finland in the metropolitan area is studied to demonstrate effectiveness of the method.