I noticed that \pgfmathsetcounter, etc. only work in local scope. It seems to me that it would be saner to match the definition of \setcounter which works on the global scope by default.
If this is by design, then this should be documented.
I added a note in the documentation. This is by design (I presume, I did not write the code...), and, anyway, global assignments should be avoided whenever possible. In this sense, I believe that the decision to make \setcounter global is the wrong one, not that \pgfmathsetcounter is local...