Dear Statalist,

This is my first time on this forum and untill now I have found a lot of answers for my question on here.
However, this time I'm struggling with a question where I can't find the answer for on this forum.
I am using panel data with different companies in different countries and years. I want to make a dummy variable called Dominant, where a firm is dominant if it has the highest net sales out of its industry in its country by year. So per year and industry one firm should be assigned an 1. I did this by using the following commands:
Code:
egen Max_Sales = max( Net_Sales ), by( cntrycde SICCODE year)
gen Dominant=1 if Net_Sales== Max_Sales
replace Dominant=0 if Dominant==.
When the net sales aren't too big this works perfectly. However, when the net sales are very big they will be described as 1.46e+09 for example. At this point stata doesn't recognize the max sales as the same value as the net sales: Array



The selected part is year 2010 for South Korean firms with the same industry code. The biggest value of net sales (8.32e+09) is the same for the max_sales variable I created, but still the Dominant value in row 21151 doesn't get a 1.

I tried to fix this by changing the format and therefore using the following commands:
Code:
format %15.0g Net_Sales
egen Max_Sales = max( Net_Sales ), by( cntrycde SICCODE year)
format %15.0g Max_Sales
gen Dominant=1 if Net_Sales== Max_Sales
replace Dominant=0 if Dominant==.
Then I can see that Stata changes the value instead of copying the exact maximum value of net sales to my created variable Max_Sales. As you can see in the first column and the last column, where observation 21152 still does not get a 1 for Dominant while this should be the case: Array



I hope that my problem is clear, I need the Max_Sales value in row 21152 to be exactly the same as the Net_sales variable but I can't figure out how to get this.

Any ideas would be highly appreciated.

Thank you in advance,
Lotte