Hello all,

I'm trying to estimate a gravity model with trade data that is disaggregated at industry level and trying to include country-pair fixed effects in my regression. I'm aware when you want to generate country pair id, you egen pairid = group(importer exporter). But what I have been wondering is when you generate pair id like above, that means a pair of USA(importer) and Canada(exporter) would be different from a pair of Canada(importer) and USA(exporter).

So my question is, is it right to run regression with country-pair fe with pair ids just like above? From my understanding, we include country-pair fe to observe heterogeneity between each country pair. So then, wouldn't it be more appropriate for me to have the same pair id for the pair of USA and Canda regardless of which one of these two country is importer or exporter? (Canada USA(imp)-Canada(exp) and Canada(imp)-USA(exp) both pair should have the same pair id since they both pairs are comprised of the same countries) Secondly, if so, then what is the command I can use to generate the same pair id for the USA and Canada regardless of them being importer or exporter?

Thank you