We examine two-stage games where all players choose the parameters of social preferences at the first stage and play the n-person prisoner's dilemma at the second stage with perfect and imperfect information. This model expresses situations where players can choose how much they depend on the other players' payoffs. In this model, we get the following results. If the game has perfect information, cooperation among all players can be attained in an equilibrium by punishing a deviating player. If each player plays the n-person prisoner's dilemma without knowing the choices of the other players at the first stage, cooperation among a constant number of players can be attained in an equilibrium. In addition, we study two-stage games where all players choose how much they are concerned with the social welfare at the first stage and play the n-person prisoner's dilemma at the second stage. We show that when the players are more concerned with the minimum payoff, the number of players who cooperate at the second stage in an equilibrium weakly decreases.