The principal component analysis (PCA) has been extensively studied and proved to be a sophisticated technique for the dimension reduction and the index construction of multidimensional stationary time series. However, the PCA method is often susceptible to external trends of original variables in real-world applications, when data present non-stationarity. In this paper, we propose a non-stationary principal component analysis (NSPCA) for multidimensional time series in the presence of non-stationarity. The new method is based on detrended cross-correlation analysis. We theoretically derive the coefficients relating to the combinations of original variables in the NSPCA method. We also apply the NSPCA method to the autoregressive model, Gaussian distributed variables as well as stock sectors in Chinese stock markets, and compare it with the traditional PCA method. We find that the NSPCA method has the advantage to detect intrinsic cross-correlations among variables and identify the patterns of data in the case of non-stationarity, minimizing the effects of external trends which often make the PCA yields few components assigning similar loadings to all variables.