  We study the supersymmetric standard model with multiple Higgs doublets with
gauged $\mathrm{U}(1)_X$ flavor symmetry. When the flavor symmetry is broken by
the vacuum expectation value of flavon, the $\mathbb{Z}_3$ symmetry $M_3$
called matter triality remains and it prohibits the baryon number violation up
to dimension-5 operators. We study the contribution of the extra-Higgs fields
to the anomaly cancellation of flavor symmetry and analyze the mass spectra
including the multiple generations of Higgs fields as well as quarks and
leptons. We show a series of $\mathrm{U}(1)_X$ charge assignments, which
reproduce the observed masses and mixing angles of quark and lepton. We also
find that, with such realistic charge assignments, the extra-Higgs fields
obtain masses around the intermediate scale and decouple from the electroweak
physics because of the holomorphy of superpotential.
