Perhaps this is the wrong place for this, but I'm not quite sure where to put it.
I have a very large compressed SAS file in .XPT format. I want to convert it to a comma separated format. The file is too large to load in R. I do not have SAS on my machine, and do not have any way of getting it.
Any suggestions? Is there a converter somewhere? I cannot find one using google.
Python has xport Library https://pypi.python.org/pypi/xport/ install library
$ pip install xport
$ python -m xport example.xpt > example.csv
If you can use Python, I've just published a library that might be able to help with this. Dumping to a CSV would look something like this (untested):
import xport, csv
with xport.XportReader('in.xpt') as reader:
with open('out.csv', 'rb') as out:
writer = csv.DictWriter(out, [f['name'] for f in reader.fields])
for row in reader:
writer.writerow(row)
The files are treated as streams, so it shouldn't matter how large the file is (as long as you don't call reader.record_count(), which has to seek to the end of the file).
Let me know if you try this -- the library works for me, but I haven't tried it on many .xpt files yet.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With