kwallis2 is not part of official Stata, but a user-written command, and now very old. You should be using kwallis, which is part of official Stata.
If you look at the help for kwallis, it will open the Stata manual entry for the command and you will find the precise formula at the end of the chapter. All of Stata's commands are documented with precise details of formulas and references.
I don't know why the other poster is pointing you towards bootleg versions of SPSS. Statistical software developers deserve the revenue from their sales. I presume that your institution has a policy on pirated software.