You can refer to the help file: help memory. some tips is presented as follow:
Set maximum number of variables in Stata/MP and Stata/SE
set maxvar # [, permanently]
where # is specified in bytes, kilobytes, megabytes, or gigabytes (b, k, m, and g may be typed in uppercase),
with the default being k, and where 2,048 < # < 32,767 in set maxvar.