macro to generate gain and ped files