\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. The saved text is accessed by a \usebox command.
The \sbox and \savebox commands are declarations with the usual rules for scope.
The \sbox command is robust; the \savebox command is fragile.