I am currently using pgf-pie package and I face a problem when I write the pgf-pie content using \newcommand instruction. The following MWE
\documentclass{standalone}
\usepackage{pgf-pie}
\usetikzlibrary{shadows}
\begin{document}
\newcommand{\testpie}{10/ A , 20/ B , 30/ C , 40/ D}
\begin{tikzpicture}
\begin{pie}[
text = inside,
scale font,
style = drop shadow
]
{
\testpie
}
\end{pie}
\end{tikzpicture}
\end{document}
generates the following error
! Package PGF Math Error: Unknown function `A' (in '10/ A , 20/ B , 30/ C , 40/D').
The final goal is to automatically generate the "fraction" sequence by reading a pgfplotstable.
Edit:
Going back to initial code I have something like that
\documentclass{standalone}
\usepackage{pgfplotstable}
\usepackage{pgf-pie}
\usepackage{xstring}
\pgfplotstableread[col sep=comma]{
Year,TB,B,AB,P,NA
2008/2009,15,38,15,0,31
2009/2010,13,25,38,0,25
2010/2011,17,50,8,17,8
}{\mention}
%% Feel free to improve the next lines
\newcommand{\pieplot}[1]{%
\pgfplotstableforeachcolumnelement{Year}\of{#1}\as\cell{%
\IfStrEq{\cell}{2008/2009}{%
\pgfplotsforeachungrouped \x in {TB,B,AB,P,NA}{%
\pgfplotstablegetelem{\pgfplotstablerow}{\x}\of{#1}
\pgfmathtruncatemacro\val{\pgfplotsretval}
\ifnum\val=0
\else
\val / \x
\IfStrEq{\x}{NA}{}{,}
\fi
}
}
}
}
\begin{document}
\pieplot{\mention}
\end{document}
which generates the right "fraction" sequence but fails when I use \pie command even with \mypie command.

\testpiemust be expanded before it passed as an argument. – Marco Daniel Sep 7 '12 at 18:30