In this paper, we study the estimation of the unbalanced panel data partially linear models with a one-way error components structure. A weighted semiparametric least squares estimator (WSLSE) is developed using polynomial spline approximation and least squares. We show that the WSLSE is asymptotically more efficient than the corresponding unweighted estimator for both parametric and nonparametric components of the model. This is a significant improvement over previous results in the literature which showed that the simply weighting technique can only improve the estimation of the parametric component. The asymptotic normalities of the proposed WSLSE are also established. Another focus of this paper is to provide a variable selection procedure to select significant covariates in the parametric part, based on a combination of the nonconcave penalization and the weighted semiparametric least squares. The proposed procedure simultaneously selects significant covariates and estimates unknown parameters. With a proper choice of regularization parameters and penalty function, the resulted estimator is shown to possess an oracle property. Simulation studies and an example of application on a set of hormone data are used to demonstrate this proposed procedure.