\sbox{cmd}[text]
\savebox{cmd}[width][pos]{text}
These commands typeset text in a box just as for \mbox or \makebox. However, instead of printing the resulting box, they save it in the LaTeX command cmd, which must have been declared with \newsavebox.