The xtewreg Stata command
If you just want to get the Stata command, use [. ssc install xtewreg] from your Stata console. You can then use [. help xtewreg] to learn more about how to use the command.
If you’d like to view the command source code or make changes, the code is available on my GitHub.
Downloading N-SAR forms from the SEC EDGAR
You can find Python + Stata code to deal with downloading, parsing and analyzing N-SAR data from EDGAR on my GitHub