You say that you get the error missing number, but it is always best to look at the first error. If you (or your editor) scroll past an error TeX will try to recover but such recovery often introduces spurious following errors.
\documentclass{article}
\usepackage{amsmath}
\newcommand{stackonetwo}{\begin{smallmatrix} 1 \\ 2 \end{smallmatrix}}
\begin{document}
\end{document}
Produces the error
! LaTeX Error: Missing \begin{document}.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.5 ...egin{smallmatrix} 1 \\ 2 \end{smallmatrix}}
only if you scroll past that do you get
! Missing number, treated as zero.
<to be read again>
a
l.5 ...egin{smallmatrix} 1 \\ 2 \end{smallmatrix}}
?
then if you scroll past that TeX gets really confused and you get
! Missing control sequence inserted.
<inserted text>
\inaccessible
l.5 ...egin{smallmatrix} 1 \\ 2 \end{smallmatrix}}
?
the initial error is due to the missing \
in \stackonetwo
which is causing the letters to "fall out" of the definition and start to be typeset as a paragraph of text before \begin{document}
If you fix that error then
\documentclass{article}
\usepackage{amsmath}
\newcommand{\stackonetwo}{\begin{smallmatrix} 1 \\ 2 \end{smallmatrix}}
\begin{document}
\end{document}
runs without error and will typeset the matrix as intended when used in math mode.
stackonetwo
isn't preceded by a backslash, so it isn't a valid control sequence. If, once you've added the backslash the error still occurs, add a second pair of backslashes around the entire contents of the macro argument. If that doesn't get rid of the error, then it's something else and more information is needed.