Molecular dynamics simulations are performed to determine the solubility and diffusion coefficient of carbon dioxide and nitrogen in poly(methyl methacrylate) (PMMA). The solubilities of CO2 in the polymer are calculated employing our grand canonical ensemble simulation method, fixing the target excess chemical potential of CO2 in the polymer and varying the number of CO2 molecules in the polymer matrix till establishing equilibrium. It is shown that the calculated sorption isotherms of CO2 in PMMA, employing this method well agrees with experiment. Our results on the diffusion coefficients of CO2 and N-2 in PMMA are shown to obey a common hopping mechanism. It is shown that the higher solubility of CO2 than that of N-2 is a consequence of more attractive interactions between the carbonyl group of polymer and the sorbent. While the residence time of CO2 beside the carbonyl group of polymer is about three times higher than that of N-2, the diffusion coefficient of CO2 in PMMA is higher than that of N-2. The higher diffusion coefficient of CO2, compared to N-2, in PMMA is shown to be due to the higher (approximate to 3 times) swelling of polymer upon CO2 uptake. (C) 2013 AIP Publishing LLC.