If your have 2 groups with means $\bar X_i$ and sizes $n_i,$ for $ i = 1,2,$ then the mean of the two groups combined is $$\bar X_c = (n_1\bar X_1 +n_2\bar X_2)/(n_1+n_2).$$ If you know the two group means and sample sizes, then isthis method does not require you to have the two original samples.
Demonstration in R:
set.seed(2021)
x1 = rnorm(10, 100, 15)
x2 = rnorm(20, 120, 20)
# Two ways to get the mean of the two groups combined
# [formula and concatenation].
ac = (length(x1)*mean(x1) + length(x2)*mean(x2)) /
(length(x1)+length(x2))
ac
[1] 115.8537
mean(c(x1, x2)) # mean of concatenation
[1] 115.8537
By contrast...
# One way to get the median of the two groups combined:
median(c(x1, x2))
[1] 113.6022
A formula analogous to the one above for means does not work for medians (or other quantiles). [as below]. To get the the median of two groups combined, you need to concatenate the two groups to make the combined group and then find the median of the two groups combined [as above].
(length(x1)*median(x1) + length(x2)*median(x2)) /
(length(x1)+length(x2))
[1] 115.1819 # wrong median for groups combined