Hello every one, I am currently estimating a model in Stata 15, and I have a dataset in which I have the dependent Variable as trade exports divided in 3 categories Margins of export.

but when i run the command: xtset pairid StartYear
it says: repeated time values within panel

that is because I have 3 categories of margins for each year, so I have the repetition of each year 3 times. As you can see in a representation of my dataset i made below



--------------------------------------------------------------------------------------------DVmagins-c1 ----DVmargins-c2------ Independent variable X1
country-1 country-2 Category 1 - Increase margins- year = 2000 -------4332 ----------- 434----------------------90

country-1 country-2 Category 2- decrease margins - year = 2000 --------3445---------------3344 ------------------90

country-1 country-2 Category 3- Extinct margins - year = 2000 -----------44545----------- 2343 --------------------90

country-1 country-2 Category 1 - Increase margins- year = 2001--------- 1335------------- 865 ---------------------88

country-1 country-2 Category 2 - decrease margins year = 2001----------- 345-------------- 98---------------------- 88

country-1 country-2 Category 3- Extinct margins year = 2001--------------- 245 -------------105 ----------------------88



So as you can see, each one of the 3 categories has a different value for each year, therefore, I have 3 observation of my DV variable for each year .
but when comes to my independet variables, I have one single observation per year, but I had to repeat each IV observation 3 times.


So thinking about the solution I thought in making my Dependent variable a mean of the three categories so , the observations can become one for each year, and therefore, the years do not duplicates. like that my IVs will also stay one single observation per year without repeating.


and becomes like this> --------------
DVmagins-c1 DVmargins-c2 Independent variable X1
country-1 country-2 year = 2000 ------4332 -------------434-------------------- 90
country-1 country-2 year = 2001 ------1335 -------------865 --------------------88

So how I can make these 3 categories become one, like a mean of all of them, so that instead I have each year repeated three times, I have one mean for one year repeated only once?

I have tried like this>
egen Margins =rowmean(DV_MarginsC2 DV_MarginsC1)

egen Margins =rowmean(Category 1 category 2 Category 3)
I have used collapse command like this


collapse DV_MarginsC1 DV_MarginsC2, by(COUNTRY_C1 COUNTRY_C2 StartYear

I do not know what else to do. Could you guys give a help?
An option would be go to excel again and make the mean of the categories, so that it gets one observation per year, that represents all the categories but it seems costly I would like to try a solution through Stata. Thank you