I have 140,000 firms for 2010-2015. I want to check whether the industrial code (indcode) is consistent or not within 2010-2015. If a firm produces the same product within 6 years, then indcode must be identical for 6 years. But in some case, the indcode is not identical even though the firm produce a same product during 6 years . For this inconsistent industrial code I have to edit with the majority indcode during six years. I did with the following command to identify incosistent indcode then I edit manually:

Code:
by firmcode: gen nyear=[_N]
by firmcode, sort: check2 = total(indcode)
gen check2=check1/indcode
edit year firmcode indcode nyear check1 check2 if check2!=nyear
As a result, I have to correct the industrial code of 17,844 firms manually by seeing their historical data and type of product. It is time consuming. I am wondering if I can edit with STATA command, not manually. Can you please share the STATA command how to replace inconsistent industrial code with the majority indcode within 6 years?