
Wouldn't the first term below leads to the final term?
$$\hat{\beta_1}={\sum_{i=1}^n c_iy_i} = {\sum_{i=1}^n \frac{(x_i-\bar{x})(y_i)}{SXX}} = {\sum_{i=1}^n \frac{(x_i-\bar{x})(y_i)}{{\sum\limits_{i=1}^n (x_i-\bar{x})^2}}} = \frac{SXY}{SXX},$$ which is very different from $$\frac{\sum\limits_{i=1}^n{(x_i-\bar{x})(y_i)}}{{\sum\limits_{i=1}^n (x_i-\bar{x})^2}} = \frac{SXY}{SXX}=\hat{\beta_1}.$$
I am confused about how, in the first line, the author factored out was able to factor out the $SXX$ term from inside the summation.
\begin{align*} \widehat{β}_1 &= \sum_{k = 1}^n \frac{(x_k - \overline{x}) y_k}{S_{XX}} = \sum_{k = 1}^n \frac{(x_k - \overline{x}) y_k}{\displaystyle \sum_{j = 1}^n (x_j - \overline{x})^2}\\ &= \frac{1}{\displaystyle \sum_{j = 1}^n (x_j - \overline{x})^2} · \sum_{k = 1}^n (x_k - \overline{x}) y_k = \frac{\displaystyle \sum_{k = 1}^n (x_k - \overline{x}) y_k}{\displaystyle \sum_{j = 1}^n (x_j - \overline{x})^2}. \end{align*}