You can use the estat overid postestimation command directly after running your xtdpdgmm regression. This will provide you with Hansen's J test for all overidentifying restrictions. If you wish to obtain difference-in-Hansen tests, you will have to run regressions for the restricted and unrestricted models, store the estimation results from the first regression under a

As an aside: You are using the option gmmiv(

*name*and then use estat overid*name*after the second regression.As an aside: You are using the option gmmiv(

*varlist*, difference) which creates first differences of the instruments for the level equation. If that is what you intend, please just ignore this comment. If instead you aim to obtain instruments for the first-differenced equation, the correct syntax would be gmmiv(*varlist*, model(difference)).
## Comment