We present an x-ray magnetic circular dichroism (XMCD) study performed at the Sm and Er ${L}_{2,3}$-edges for the ${R}_{2}{\mathrm{Fe}}_{17}$ compounds $(R=\mathrm{rare}$ earth) and their ${R}_{2}{\mathrm{Fe}}_{17}{\mathrm{H}}_{x}$ and ${R}_{2}{\mathrm{Fe}}_{17}{\mathrm{N}}_{x}$ derivatives. The modification of the magnetocrystalline anisotropy by interstitial nitrogen atoms affects the shape of the XMCD signals recorded at both Sm and Er ${L}_{3}$ edge. On the other hand, while the change from planar to uniaxial anisotropy does not modify the Sm ${L}_{2}$-edge XMCD signal, the sign of the Er ${L}_{2}$-edge XMCD spectrum is reversed. These results are discussed in terms of the effect of the magnetocrystalline anisotropy on the XMCD spectra at rare-earth ${L}_{2,3}$ absorption edges of R-Fe intermetallic systems.