Here's the extended version for also counting the number that appeared the most after the last \countappearances declaration.
\documentclass{beamer}
\usepackage[danish]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{xparse}
\ExplSyntaxOn
\prop_new:N \g_svend_elev_prop
\prop_gput:Nnn \g_svend_elev_prop {A} {6}
\prop_gput:Nnn \g_svend_elev_prop {B} {0}
\prop_gput:Nnn \g_svend_elev_prop {C} {0}
\prop_gput:Nnn \g_svend_elev_prop {D} {3}
\prop_gput:Nnn \g_svend_elev_prop {E} {0}
\prop_gput:Nnn \g_svend_elev_prop {F} {2}
\prop_gput:Nnn \g_svend_elev_prop {G} {1}
\prop_gput:Nnn \g_svend_elev_prop {H} {1}
\prop_gput:Nnn \g_svend_elev_prop {I} {1}
\prop_gput:Nnn \g_svend_elev_prop {J} {5}
\prop_gput:Nnn \g_svend_elev_prop {K} {0}
\prop_gput:Nnn \g_svend_elev_prop {L} {3}
\prop_gput:Nnn \g_svend_elev_prop {M} {7}
\prop_gput:Nnn \g_svend_elev_prop {N} {3}
\prop_gput:Nnn \g_svend_elev_prop {O} {1}
\prop_gput:Nnn \g_svend_elev_prop {P} {1}
\prop_gput:Nnn \g_svend_elev_prop {Q} {0}
\prop_gput:Nnn \g_svend_elev_prop {R} {0}
\prop_gput:Nnn \g_svend_elev_prop {S} {0}
\prop_gput:Nnn \g_svend_elev_prop {T} {2}
\prop_gput:Nnn \g_svend_elev_prop {U} {1}
\prop_gput:Nnn \g_svend_elev_prop {V} {2}
\prop_gput:Nnn \g_svend_elev_prop {W} {0}
\prop_gput:Nnn \g_svend_elev_prop {X} {2}
\prop_gput:Nnn \g_svend_elev_prop {Y} {1}
\prop_gput:Nnn \g_svend_elev_prop {Z} {1}
\prop_gput:Nnn \g_svend_elev_prop {Aa} {4}
\prop_gput:Nnn \g_svend_elev_prop {Ab} {6}
\prop_gput:Nnn \g_svend_elev_prop {Ac} {1}
\prop_gput:Nnn \g_svend_elev_prop {Ad} {1}
\prop_gput:Nnn \g_svend_elev_prop {Ae} {6}
\prop_gput:Nnn \g_svend_elev_prop {Af} {2}
\prop_gput:Nnn \g_svend_elev_prop {Ag} {0}
\prop_gput:Nnn \g_svend_elev_prop {Ah} {3}
\prop_gput:Nnn \g_svend_elev_prop {Ai} {2}
\prop_gput:Nnn \g_svend_elev_prop {Aj} {1}
\prop_gput:Nnn \g_svend_elev_prop {Ak} {0}
\prop_gput:Nnn \g_svend_elev_prop {Al} {0}
\prop_gput:Nnn \g_svend_elev_prop {Am} {0}
\prop_gput:Nnn \g_svend_elev_prop {An} {0}
\prop_gput:Nnn \g_svend_elev_prop {Ao} {0}
\prop_gput:Nnn \g_svend_elev_prop {Ap} {4}
\prop_new:N \g_svend_count_prop
\prop_new:N \g_svend_count_zero_prop
\prop_gput:Nnn \g_svend_count_zero_prop { 0 } { 0 }
\prop_gput:Nnn \g_svend_count_zero_prop { 1 } { 0 }
\prop_gput:Nnn \g_svend_count_zero_prop { 2 } { 0 }
\prop_gput:Nnn \g_svend_count_zero_prop { 3 } { 0 }
\prop_gput:Nnn \g_svend_count_zero_prop { 4 } { 0 }
\prop_gput:Nnn \g_svend_count_zero_prop { 5 } { 0 }
\prop_gput:Nnn \g_svend_count_zero_prop { 6 } { 0 }
\prop_gput:Nnn \g_svend_count_zero_prop { 7 } { 0 }
\prop_gset_eq:NN \g_svend_count_prop \g_svend_count_zero_prop
\tl_new:N \l_svend_number_tl
\tl_new:N \l_svend_count_tl
\tl_new:N \l_svend_mostnum_tl
\tl_new:N \l_svend_mostcount_tl
\DeclareExpandableDocumentCommand{\elev}{m}
{
\svend_get_item:n { #1 }
}
\NewDocumentCommand{\countappearances}{}
{
% now \elev will also count
\cs_set_eq:NN \elev \svend_get_item_count:n
% reinitialize the counter property list
\prop_set_eq:NN \g_svend_count_prop \g_svend_count_zero_prop
}
\NewDocumentCommand{\getmost}{m}
{
\tl_set:Nn \l_svend_mostnum_tl { 0 }
\tl_set:Nx \l_svend_mostcount_tl { \prop_item:Nn \g_svend_count_prop { 0 } }
\int_step_inline:nnnn { 1 } { 1 } { 7 }
{
\int_compare:xT { \prop_item:Nn \g_svend_count_prop { ##1 } > \l_svend_mostcount_tl }
{
\tl_set:Nn \l_svend_mostnum_tl { ##1 }
\tl_set:Nx \l_svend_mostcount_tl { \prop_item:Nn \g_svend_count_prop { ##1 } }
}
}
\tl_set_eq:NN \mostnum \l_svend_mostnum_tl
\tl_set_eq:NN \mostcount \l_svend_mostcount_tl
#1
}
\cs_generate_variant:Nn \int_compare:nT { x }
\DeclareExpandableDocumentCommand{\HowMany}{m}
{
\prop_item:Nn \g_svend_count_prop { #1 }
}
\cs_new:Npn \svend_get_item:n #1
{
\prop_item:Nn \g_svend_elev_prop { #1 }
}
\cs_new_protected:Npn \svend_get_item_count:n #1
{
\tl_set:Nx \l_svend_number_tl { \svend_get_item:n { #1 } }
% print the entry
\tl_use:N \l_svend_number_tl
% get the current count
\tl_set:Nx \l_svend_count_tl
{
\prop_item:NV \g_svend_count_prop \l_svend_number_tl
}
% advance the count by 1
\tl_set:Nx \l_svend_count_tl { \int_to_arabic:n { \l_svend_count_tl + 1 } }
% update the property
\prop_gput:NVV \g_svend_count_prop \l_svend_number_tl \l_svend_count_tl
}
\cs_generate_variant:Nn \prop_item:Nn { NV }
\cs_generate_variant:Nn \prop_gput:Nnn { NVV }
\ExplSyntaxOff
\begin{document}
\begin{frame}
\begin{table}
\centering
\small
\countappearances
\begin{tabular}{*{14}{c}}
\toprule
\elev{A} & \elev{B} & \elev{C} & \elev{D} & \elev{E} & \elev{F} & \elev{G} &
\elev{H} & \elev{I} & \elev{J} & \elev{K} & \elev{L} & \elev{M} & \elev{N} \\[0.5ex]
\elev{O} & \elev{P} & \elev{Q} & \elev{R} & \elev{S} & \elev{T} & \elev{U} &
\elev{V} & \elev{W} & \elev{X} & \elev{Y} & \elev{Z} & \elev{Aa} & \elev{Ab} \\[0.5ex]
\elev{Ac} & \elev{Ad} & \elev{Ae} & \elev{Af} & \elev{Ag} & \elev{Ah} & \elev{Ai} &
\elev{Aj} & \elev{Ak} & \elev{Al} & \elev{Am} & \elev{An} & \elev{Ao} & \elev{Ap} \\
\bottomrule
\end{tabular}
\bigskip
\begin{tabular}{*{8}{c}}
\toprule
\multicolumn{8}{c}{How many} \\
\midrule
0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 \\
\HowMany{0} &
\HowMany{1} &
\HowMany{2} &
\HowMany{3} &
\HowMany{4} &
\HowMany{5} &
\HowMany{6} &
\HowMany{7} \\
\bottomrule
\end{tabular}
\bigskip
\getmost{%
The number that appeared the most is \mostnum;
it appeared \mostcount\ times.}
\end{table}
\end{frame}
\end{document}
The macro \getmost takes as parameter the text you want to print. If you use \getmost{}, no text will be printed, but you'll have available \mostnum and \mostcount anyway. Note that this is local to the group where \countappearances appears. It's not difficult to make it global, if needed.
