The paper determines the classes of functions and classes of bases and pivotal sets for the set $S_p$ of selfdual functions of $p$-valued logic ($p$-prime number). For this set and the sets $L_p$ (set of linear functions of $p$-valued logic) and $T$ (set of semi-degenerate or Slupecki functions of three-valued logic) there are determined the numbers of $n$-ary functions and symmetric $n$-ary functions for each class of functions, the numbers of bases, pivotal sets, symmetric bases and symmetric pivotal sets of each rank, consisting of $n$-ary functions or consisting of functions depending on $n$ variables at most.