High performance TAXSIM with netcat
The following is experimental, but may offer faster and more reliable internet taxsim, especially with large files.
The netcat interface to taxsim has been failing for some users since late March 2009. An upgrade to version 9 is suggested as it does not use netcat.
TAXSIM Version 8 is available via plain tcp networking without the overhead of http processing. This is also the underlying interface used by the taxsim8.ado stata command. It requires the user have a "netcat" or equivalent program on her system.
Step 1 - Obtain Netcat.
Netcat may already be available on your system under that name or as "nc", "snetcat" or "hobbit". Try:
whereis nc netcat snetcat gnetcat hobbitto find out which is available on your system. One of these should work. Once you have the correct name, you can create an alias to connect it to the name used in taxsim8.ado:
alias nc gnetcatIf none are available, your system administrator can easily install it in Unix. In fact, you don't need his approval, you can install the binary in your home directory if necessary. For RedHat Linux try:
yum install nc
For windows I found . You can write to me and I can send you a netcat source. You should drop it into c:\winnt\system32 or some other directory on the executable path. Lately we have noticed that updates to the windows firewall prevent netcat from receiving data. You may have to turn off the firewall (start|control-panel|security-center) to get results. Please note that you don't want to turn off the firewall and install an executable from a web site unless you know and trust the source. I am assuming anyone using taxsim is familiar with the NBER and has spoken with me.
Step-2 Test Netcat
You should test netcat at this point, to confirm that it works. If you open a command window and type:
echo 1 256 / | nc taxsim8.nber.org 1040you should get the reply:
TAXSIM OKwith nc or netcat, there is a "-v" flag that will tell you if a connection has been made. If you get an error message, be sure to copy the entire transaction down and include it in any support request.
Step 3. Running taxsim
Now you are ready to use taxsim8.ado within Stata, or you can take a file just as described on the TAXSIM web page and send it directly to TAXSIM, bypassing the web server and Stata:
nc taxsim8.nber.org 1040 <txpydata.raw >taxsim-results.rawThis sends txpydata.raw to port 1040 on our taxsim host. The results come back to the standard output on a line-by-line basis with just a little buffering, so even very large files can be processed. The variables are the same as on the TAXSIM web interface. If you are using taxsim8 and getting a "no variables defined" error message, I will ask you to set the "debug" flag to the taxsim8 command (which will save the intermediate taxpayer data file to the current directory), and then try the above "nc" command to send that file to the tax calculator.
Step 3. Customization
If the default marginal tax rate calculation or level of detail is not to your liking, it is possible to change either. Add an initial line to taxsim-file.ext with three values and a slash. The first is a constant "8", the second indicates the type of marginal tax calculation, the third indicates the level of detail returned. The slash indicates to TAXSIM that the line is control information and not data.
8 85 0 /
The choices for the marginal tax calculation are:
- 11 - Wages
- 70 - Long term capital gains
- 85 - Primary wage earner
- 86 - Secondary wage earner
The choices for detail are:
- 0 - standard
- 2 - full
- 5 - with text description
nc taxsim8.nber.org 1040 <<eof 8 70 2 / 1 1989 13 3 1 0 30000 0 0 0 0 0 0 0 0 0 2000 0 1 0 -1000 0 1 1989 13 3 1 0 20000 0 0 0 0 0 0 0 0 0 2000 0 1 0 -1000 0 0 254 /Will provide detailed results and calculate the marginal rate for long term capital gains for two individuals whose characteristics are provided.
The last line ("0 254 /") serves as an end-of-file flag for those versions of netcat which do not handle this correctly and may not be necessary in your environment.
Because the netcat interface is so new, I would like to hear from users - my number is 617-588-0343.
Daniel Feenberg
feenberg at nber dotte org
Last modified 5 June 2009