  Halo merger trees are constructed from ELUCID, a constrained $N$-body
simulation in the Sloan Digital Sky Survey (SDSS) volume. These merger trees
are used to populate dark matter halos with galaxies according to an empirical
model of galaxy formation. Mock catalogs in the SDSS sky coverage are
constructed, which can be used to study the spatial distribution of galaxies in
the low-$z$ Universe. These mock catalogs are used to quantify the cosmic
variance in the galaxy stellar mass function (GSMF) measured from the SDSS
survey. The GSMF estimated from the SDSS magnitude-limited sample can be
affected significantly by the presence of the under-dense region at $z<0.03$,
so that the low-mass end of the function can be underestimated significantly.
Several existing methods designed to deal with the effects of the cosmic
variance in the estimate of GSMF are tested, and none is found to be able to
fully account for the cosmic variance. We propose a method based on the
conditional stellar mass functions in dark matter halos, which can provide an
unbiased estimate of the global GSMF. The application of the method to the SDSS
data shows that the GSMF has a significant upturn at $M_*< 10^{9.5} h^{-1}{\rm
M}_\odot$, which has been missed in many earlier measurements of the local
GSMF.
