We propose a scheme to generate an electromagnetically induced grating via coherently driven four-level atoms in a N-type configuration in the presence of a standing signal field, a coupling field and a probe field. We show that a nearly ideal phase grating can be realized by adjusting the frequency detuning of signal field, the interaction length of atomic medium, and the ratio of the intensity between the signal field and the coupling field. The first-order diffraction efficiency of the grating is about 29.9 %, which is close to that of an ideal sinuso...