Low level Interface to Taxsim with a SAS example
TAXSIM is a network service available via plain ftp. Notice that it is a service, and not a program that is provided. You upload the data, and download the results. This is also the underlying interface used by the Taxsim on the web, or from Stata. A scriptable ftp client is found on all Windows and Unix/Linux systems.
Step-1 Test ftp
You should ftp to make sure it is installed, and not blocked at your firewall.
Step 2. Running Taxsim
You will need a file in the same format described at for uploading on the Taxsim web page. You can log onto taxsimftp.nber.org with the username 'taxsim' and password '02138'. Then you upload your file to directory /tmp under any arbitrary name. Once the file is completely uploaded, you can download the calculated results by tacking .taxsim onto the name used in the upload. The calculation actually occurs during the download on our server. Old input files are deleted once a day.
That's it. You don't really need any more information. Aside from filewalls, you only need to create and upload the file described on the Taxsim web page. But please follow the instructions there carefully. If there are errors in the file, such as non-decimal characters or missing value codes, then the downloading will stop, and the last few lines of that .taxsim file will contain the error message.
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 with a control line. A control line has 27 numeric values, but only the first three are used. The first value is a constant "27" (the Taxsim verion number), the second indicates the type of marginal tax calculation, and the third indicates the level of detail to be returned. The meanings of these choices are described on the Taxsim web page.
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
In case you are wondering how Taxsim recoginzes a control line, it is by a "year" less than 256. Control lines can be anyplace in the file, and affect subsequent calculations.
An example:
27 70 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1970 0 2 55 52 0 0 0 0 0 0 0 0 0 100000 0 0 0 0 0 0 0 0 0 0 0 1 1970 0 2 55 52 2 2 2 2 0 0 0 0 0 100000 0 0 0 0 0 0 0 0 0 0 0The first "control" record tells Taxsim to provide detailed results and calculate the marginal rate for long term capital gains. The control record is optional and if it appears after the first record it affects only subsequent records. The second record describes a 1970 joint return with no dependents and 100000 in long term capital gains income. The third record adds 2 young children.
Optional Tax Plans
Control variables 4 and 5 can be used for optional tax plans. The option number in variable 4 and the parameter as variable 5. For example,9 70 2 50 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0will suppress the AMT calculation.
A SAS application
Because SAS has a built-in ftp client, you can "call" taxsim from within a SAS program. There is a SAS taxsim macro. But here is a educational demonstration of the low level call, not using the macro:
/* Using the SAS FTP function with Taxsim 1) Need to create a unique filename - &DATAFILE is taken from the time of day 2) Convert any missing values into zeros for taxsim 3) upload the values as ASCII 4) using the .taxsim file extension on the filename, fetch the results 5) fetch the .msg file and print that to the sas log. Important References: http://www.nber.org/taxsim/taxsim27/ http://www.nber.org/taxsim/taxsim27/macro.sas http://www.nber.org/taxsim/taxsim27/example.sas http://support.sas.com/documentation/cdl/en/lrdict/61724/HTML/default/a000178980.htm http://support.sas.com/documentation/cdl/en/lrdict/61724/HTML/default/a001281561.htm BUGS: Because &SYSTIME doesn't change within a single SAS run, the you will need a different method of creating &DATAFILE if you wish to have several taxsim runs in a single SAS run. Before reporting communication problems, please uncomment the "debug" option on the filename statements, rerun, and send the log file to me. Daniel Feenberg feenberg@nber.org 617-588-0343 */ /* Demonstrate SAS Taxsim with a one record dataset. */ %GLOBAL TVARS; %MACRO TVARS; /*List of variables to be sent to Taxsim */ taxsimid year state mstat depx agex pwages swages dividends otherprop pensions gssi transfers rentpaid proptax otheritem childcare ui depchild mortgage ltcg stcg; %MEND; data; input %TVARS; cards; 1 2008 -1 2 1 0 1300000 0 0 0 0 0 0 0 12000 0 0 0 1 44780 -17700 -12300 ; run; %let DATAFILE = %SUBSTR(&SYSTIME,1,2)%SUBSTR(&SYSTIME,4,2); %PUT 'Filename on taxsimftp server is:' &DATAFILE; filename txpydata ftp "&DATAFILE" host='taxsimftp.nber.org' user='taxsim' pass='02138' cd='tmp' /*debug*/; filename results ftp "&DATAFILE..taxsim" host='taxsimftp.nber.org' user='taxsim' pass='02138' cd='tmp' /*debug*/ lrecl=1024; filename errors ftp "&DATAFILE..msg" host='taxsimftp.nber.org' user='taxsim' pass='02138' cd='tmp' /*debug*/; data; set; file txpydata; if year ne . and mstat ne . and taxsimid ne .; array t %TVARS; do over t ; if t eq . then t = 0; end; put %TVARS; run; /* Read and print results directly from taxsimftp server. */ data; infile results; input taxsimid year state fiitax siitax fica frate srate ficar; run; proc print; /* Read and print to log the taxsim error message file. */ data; infile errors; input;put 'TAXSIM:' _infile_; run;
Daniel Feenberg
feenberg at nber dotte org
Last modified 10 July 2009