Jeff wrote: > Does anyone know of a python module to read a SAS Transport (XPORT) > file?
I am not aware of any native Python module to read SAS portable transport (XPORT) files (but that doesn't mean you shouldn't search for one using Google etc). However, the format of the XPORT files is publically available (see http://support.sas.com/techsup/technote/ts140.html )and I would be happy to help test such a module should you or anyone else care to write one. Be aware that the XPORT file format harks back to the days when SAS was only available on IBM mainframes, and teh specs contain some peculiarities for a post-mainframe world, such as the use of IBM double precision representation of floats (7 bits for the exponent and 56 bits for the mantissa, whereas IEEE format uses 11 bits for the exponent and 52 bits for the mantissa) - thus you have to take additional care if you want to retain the full precision expressible in the XPORT format. There are alternative routes, though. 1) The foreign package (see http://cran.r-project.org/doc/packages/foreign.pdf ) for the R statistical system (see http://www.r-project.org) contains a function read.xport which does as its name suggests. You can then use RPy (see http://rpy.sf.net) to convert the resulting R data object(s) into Python objects. Obviously you need to install R and RPy (and ideally Numeric Python too) for this to work, but they are worth installing in their own right. If your XPORT daatset is very large, then R/RPy may not be an option, as R stores everything in memory. 2) Recent (within the last 6 years or so) versions of SAS come with an XML engine, and it easy to export a SAS dataset to an XML file, which would be easier to parse and convert into Python objects than teh SAS XPORT file format, I dare say. The DTD used by SAS is also publicly available (Google for it) 3) Recent versions of SAS also come with PROC EXPORT, which you can use to dump you SAS dataset to a CSV or tab-delimited (or fixed format) text file - but be careful with representation and precision issues. You can write a SAS data step programme to accomplish the same thing in earlier versions of SAS (in fact, that's all that PROC EXPORT does, behind the scenes). Tim C -- http://mail.python.org/mailman/listinfo/python-list