A SAS macro to invoke the TAXSIM server

Note: taxsim 9 has been obsoleted. It will persist for replications only. It has not received any bug fixes since Augest 2020 and does not include TCJA. Please update to the latest version.

TAXSIM is a network service available via plain ftp for calculating federal and state income tax liabilities from survey data. Notice that it is a service, and not a program. Your SAS job uploads the data, and downloads the results. Because SAS includes a functioning ftp client invoked by the "filename" statement, it is straigtforward to write a 50 line SAS macro to invoke the TAXSIM server. With the macro the process is handled inline with the SAS code and no user intervention is required. With a good decent internet connection you should be able to run 10,000 records/minute.

If you have installed a taxsim executable on your local machine, you can start with step 3 below.

Step-1 Test ftp

You should ftp to make sure ftp is not blocked at your firewall.

Step-2 Obtain the macro

taxsim-macro.sas macro is available as http://www.nber.org/taxsim/taxsim-calc9/macro.sas. Be sure to examine the macro and understand what it is doing. You can use your own copy or It may be dynamically included in your source each time it is used:
filename taxsim URL "http://www.nber.org/taxsim-calc9/macro.sas";
%inc taxsim

Step 3. Running TAXSIM

You will need a SAS file with exactly the same 22 variables as are documented on Taxsim web page. The variable names are shown below in the example, in the same order as they are listed on that web page. You invoke taxsim with %taxsim:

%taxsim(in,out);
where "in" and "out" are filenames for the input and output files in sas binary format.

That's it. You don't really need any more information. You only need to create the file described on the Taxsim web page. But please follow the instructions there carefully. If there are errors in the file, such as negative wages or out of bounds state codes you should get a message in the sas log and a partially filled "out" file.

Step 4. Customization

If the default marginal tax rate calculation, level of detail or tax law is not to your liking, it is possible to change change them with the optional arguments. The full macro call is:

%taxsim(in,out,mtr=0,idtl=0,plan=0,planval=0);

The choices for the marginal tax (mtr) calculation are:

  • 11 - Wages
  • 70 - Long term capital gains
  • 85 - Primary wage earner
  • 86 - Secondary wage earner

The choices for detail (idtl) are:

  • 0 - standard
  • 2 - full
  • 5 - with text description (not implemented in SAS)

The choices for plan and planval are detailed here.

You are likely to want to change the integration with SAS, which will mean copying it to a local directory and editing it to suite your requirementss. The code is very easy to understand and change - don't hesitate to try this.

Important References:

    About TAXSIM.
  1. Internet Taxsim
  2. Taxsim-ftp

    About SAS and ftp.

  3. FILENAME Statement, FTP access method.
  4. SYSINDEX function.

Although this is quite a simple SAS macro, debugging problems is still a challenge. In most cases it is easier to solve problems by editing the macro into straight SAS code, and running without the macro. Before reporting communication problems, please add the "debug" option on each of the filename statements in the macro, rerun, and send the log file to me.

An Example:

filename tmac URL "http://www.nber.org/taxsim/taxsim-calc9/macro.sas"; %inc tmac; data in; input taxsimid year state mstat depx agex pwages swages dividends otherprop pensions gssi transfers rentpaid proptax otheritem childcare ui depchild mortgage ltcg stcg; cards; 1 1970 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100000 ; run; /* Invoke taxsim with 2 optional arguments */ %TAXSIM(in,out,mtr=70,idtl=2); proc print data=out

This provides detailed results and calculates the marginal rate for long term capital gains for this 1970 joint return with only long term gains for income. The resulting federal tax should be 16700.04.

Daniel Feenberg
feenberg@nber.org


Last modified August 2014