Say your data is at individual level, instrument and independent variable at city level, data on 2 years, t and t+1. If you want to include city and year fixed effects, city-year fixed effects, and cluster SE on city year, what should be the code. xi: ivreg would not let me do a GMM or specify MLE stuff like ivreg 2sls does. If I use xtivreg it does not allow me to cluster SE with fe option I guess, nor does it love my i.year*i.city sort of syntax.

I want to run either some sort of this command:
egen cityear=group(city year)
xtivreg y i.year i.city i.city*i.year w u v (x=z ), fe cluster(cityear)


or

ivregress 2sls y i.year i.city i.city*i.year w u v (x=z ), fe cluster(cityear)

Can someone please tell me the appropriate code?

and I have another issue, when my data is xtset at individual id-year xtivreg returns the following error:


the sample specifies cross-sectional data
xtivreg is not designed for cross-sectional data
use ivregress with cross-sectional data