# Build command names from composing words

I want to build commands to write the ToC of a paper. In my MWE the solution 1 works, but I do prefer the solution 2, which is not working. How can I make it work?

\documentclass{article}

\usepackage{tikz}

\newcommand{\ssxa}{test 1}
\newcommand{\ssxb}{test 2}

\begin{document}
% First solution
\foreach \i in {\ssxa,\ssxb}{%
\section{\i}
}
% Second solution (does not work)
\foreach \i in {a,b}{
\edef\j{\expandafter\csname ssx\endcsname\i}
\section{\j}
}
\end{document}

• \def\j{\csname ssx\i\endcsname} – David Carlisle Oct 10 '16 at 23:20

\documentclass{article}

\usepackage{tikz}

\newcommand{\ssxa}{test 1}
\newcommand{\ssxb}{test 2}

\begin{document}
% First solution
\foreach \i in {\ssxa,\ssxb}{%
\section{\i}
}
% Second solution (does not work)
\foreach \i in {a,b}{
\section{\csname ssx\i\endcsname}
}
\end{document}