Essentially the problem is this:

I have a variable of interest "X" and data on the values of "X" for a set of countries and years. Further, I have created an indicator variable "I" that defines each year (uniquely for each country, i.e. the indicator will not have the same value in 1969 for all countries) as part of group 1 or group 2 according to the value of another variable Y.

Now what I want to check is whether the variable X has different variance during years in group 1 versus years in group 2. I have thought of two ways of doing this

1st: A regular sdtest
Code:
sdtest X, by(I)
2nd: Collapsing the sd by country and I and performing a t-test
Code:
collapse(sd) X, by(I country)
ttest X, by(I)
Both of these tests give outputs, but I do not believe they capture what I really want, or what would statistically informative. The issue is that both tests seem to pool the countries together before testing for difference in variances, which means that differences between countries aren't really being accounted for.

Obviously I could just perform this test individually for each country, but the idea is (especially since I have many more variables than X that I could test) that I would have some sort of pooled result. How do I control for the difference between countries in this sort of test? Is there a way to perform a test for difference in variances for each country and then pool them? I have tried looking around but I have not seen much information on this sort of issue, so any help would be appreciated.