I am working with a 3rd party vendor who is requesting data sets in a SAS .XPT file. I am a web developer using C# and I have no experience with SAS.
Is it possible to create a .XPT file from scratch using a text writer?
I would assume that you have access to SAS in some form. Use of Proc Cport would be every so much easier.
You can either export all of the data sets in a library in to a single file
proc cport data=sashelp.class file='c:\folder\class.xpt';
run;
would create a transport file for the data set sashelp.class.
You can export all of the datasets in a library also
proc cport library=libname file='c:\folder\library.xpt' memtype=data;
run;
Thank you for responding.
I have no access to SAS. To be honest, this is the first time I've ever had to work with it. Typically, clients ask for CSV files as a method of data transferring but they are asking for .XPT files.
Could I even create a .XPT file without SAS?
@mmccarver wrote:
Thank you for responding.
I have no access to SAS. To be honest, this is the first time I've ever had to work with it. Typically, clients ask for CSV files as a method of data transferring but they are asking for .XPT files.
Could I even create a .XPT file without SAS?
Yes you can create a file using a language other than SAS, that can be read by SAS with the SAS XPORT engine. I believe this link will get you headed in the right direction.
If you don't have SAS I'm not sure how you can test it, perhaps post it here and someone can try to read it for you.
SAS V5 transport file format is open source. For instance this doc might help:
https://support.sas.com/techsup/technote/ts140.pdf
That being said, XPts are old, and a real pain. They are alos quite limited - variable label length and such like.
Thank you for your help. I think we are going to try to purchase a tool that can convert a .CSV file to a .XPT file. Could someone point me in the right direction? Learning SAS is outside the scope of what we develop.
The client wants
With file extension .XPT
I would like to avoid the purchasing of something we don't need.
I don't know of any tool to do that. Its should be relatively straight forward to write directly out as XPT though, the file format is well described:
Even give you some class information to get started.
The one above is v8, but you can also find v6:
http://support.sas.com/kb/46/944.html
TS140 in the above doc.
Is V8 open-source?
@mmccarver wrote:
Thank you for your help. I think we are going to try to purchase a tool that can convert a .CSV file to a .XPT file. Could someone point me in the right direction? Learning SAS is outside the scope of what we develop.
The client wants
- SAS Transport V6
With file extension .XPT
I would like to avoid the purchasing of something we don't need.
I think this may work
you can download a free trial.
Since this old thread has been re-animated there are a number of packages for creating SAS transport file.
There is the READSTAT package that is written in C. There are wrappers for call this in the HAVEN package for R.
There is a nice sas7bdat package for R.
Similarly there are packages for Python.
To be honest if you do not want to lose your client find someone in academia or on FIVERR that is a SAS programmer and let them do it. SAS is a required format by the FDA and other regulatory agencies so fooling around with open-source programs of workarounds is probably a big mistake.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.