How do I write an MPS file using GAMS and MOSEK?

GAMS can write native MPS files but they do not include any nonlinear information so they are not useful for nonlinear problems.
However, it is possible to MPS files using MOSEK as follows. Create a file name
mosek.opt
that has the content
MSK_SPAR_DATA_FILE_NAME somename.mps
and then execute the command
gams mygamsprogram
MOSEK should now write the file
somename.mps