The magnetocrystalline anisotropy in TbCu7-type SmFe7 epitaxial films has been verified in relation to the 4f-electron character. The reinforcement of the 4f intermultiplet mixing by nitrogenation is verified from an enlarged basal-plane anisotropy. The sign of the uniaxial anisotropy constant is varied from positive to negative by nitrogenation, in contradiction to behaviors in Th2Zn17-type Sm2Fe17Nx. Fe-57 Mossbauer spectroscopy and first-principles calculation revealed that the transformation of the Sm-neighboring Fe-atom plane from a rippling to a flat shape, which characterizes the Th2Zn17- and TbCu7-type local structures, markedly modulates the magnetic anisotropy, owing to the 4f semilocalized character. (C) 2016 The Japan Society of Applied Physics