Optimal stacking of multiple data sets plays a significant role in many scientific domains. The quality of stacking will affect the signal-to-noise ratio and amplitude fidelity of the stacked image. In seismic data processing, the similarity-weighted stacking makes use of the local similarity between each trace and a reference trace as the weight to stack the flattened prestack seismic data after normal moveout correction. The traditional reference trace is an approximated zero-offset trace that is calculated from a direct arithmetic mean of the data matrix along the spatial direction. However, in the case that the data matrix contains abnormal misaligned trace, erratic, and non-Gaussian random noise, the accuracy of the approximated zero-offset trace would be greatly affected, and thereby further influence the quality of stacking. We propose a novel weighted stacking method that is based on principal component analysis. The principal components of the data matrix, namely, the useful signals, are extracted based on a low-rank decomposition method by solving an optimization problem with a low-rank constraint. The optimization problem is solved via a common singular value decomposition algorithm. The low-rank decomposition of the data matrix will alleviate the influence of abnormal trace, erratic, and non-Gaussian random noise, and thus will be more robust than the traditional alternatives. We use both synthetic and field data examples to show the successful performance of the proposed approach.