Here's my proposal.
\documentclass{article}
\usepackage{xparse}
\ExplSyntaxOn
\NewDocumentCommand{\maketwoprongedlist}{m m}
{
\prop_new:c { g_squipbar_list_#1_plist }
\seq_new:c { g_squipbar_list_#1_seq }
\clist_map_inline:nn { #2 }
{
\__squipbar_list_entry:nnn {#1} ##1
}
}
\cs_new_protected:Nn \__squipbar_list_entry:nnn
{
\seq_gput_right:cn { g_squipbar_list_#1_seq } { #2 }
\prop_gput:cnn { g_squipbar_list_#1_plist } { short@#2 } { #2 }
\prop_gput:cnn { g_squipbar_list_#1_plist } { long@#2 } { #3 }
}
\NewDocumentCommand{\usetwoprongedlist}{m +m}
{
\cs_set_protected:Nn \__squipbar_list_entry:nn { #2 }
\seq_map_inline:cn { g_squipbar_list_#1_seq }
{
\__squipbar_list_entry:nn
{ \prop_item:cn { g_squipbar_list_#1_plist } { short@##1 } }
{ \prop_item:cn { g_squipbar_list_#1_plist } { long@##1 } }
}
}
\ExplSyntaxOff
\maketwoprongedlist{states}{
{NY}{New York},
{IL}{Illinois},
{TX}{Texas}
}
\begin{document}
\usetwoprongedlist{states}{%
\newpage
\section*{#2} % <-- I want to use the state name here
\begin{figure}[h!]
\centering
%\includegraphics[width=.5\textwidth]{../charts/summary/\x _compare.pdf}
\texttt{../charts/summary/#1-compare.pdf}
\caption{#2} % <-- I want to use the state name here
\end{figure}
}
\end{document}

Since I don't have your pictures, I emulated them by just printing the file name.
How does this work?
First of all, I define a list giving it a name. The items are comma separated and should consist of {<abbreviation>}{<full name>}. The first part is also used for indexing and so it should consist of characters only (but this might be overcome, in case of need).
Each part is then stored as an item in a property list, indexed as short@<abbreviation> and long@<abbreviation>. Also a sequence is maintained containing the abbreviations, for later usage; the order will be that of input.
The \usetwoprongedlist command has two arguments: the first is the list to be processed; the second argument is a template, just like the main argument to \foreach; the difference is that #1 and #2 are used to denote the short and long versions of the current item.
A scratch function is defined and then the sequence indexing the list's items is mapped, calling the scratch function with arguments
\prop_item:cn {<list name>} { short@<current item> }
and
\prop_item:cn {<list name>} { long@<current item> }
respectively. Et voilà.
\Xmight be better than\x, even though here it does not matter.) – May 21 '19 at 21:18! Package PGF Math Error: Unknown functionNew' (in '{New York,Illinois,Texas}[0]').` – squipbar May 21 '19 at 21:54"from\namelist? The error message suggests that you are using something like\def\namelist{{New York},{Illinois},{Texas}}or\def\namelist{New York,Illinois,Texas}. Also the number of{is important in\pgfmathsetmacro{\mystate}{{\namelist}[\Y]}, i.e.\pgfmathsetmacro{\mystate}{\namelist[\Y]}won't work. – May 21 '19 at 21:57". But only because I was getting an error when I included them! With them, I get! Missing number, treated as zero. <to be read again> N l.18 }~. So it looks like this solution is indexing the "N" somehow, rather than the whole fist entry, "New York" (evidence: if I change the first state to Illinois, thatNbecomes anI). – squipbar May 22 '19 at 14:39