DATA Step, Macro, Functions and more

SAS conversion tool

New Contributor
Posts: 4

SAS conversion tool

We have a third party client that would like SAS data files. 


We are web developers and would like to find a software package that can convert a .CSV file to a .XPT file. 


Does any such software exist?

Super User
Posts: 3,856

Re: SAS conversion tool

Posted in reply to mmccarver

Yes, SAS but I suspect that is not the answer you want. The XPT format is designed for moving SAS data between SAS sites running different operating systems and / or SAS versions. It isn't designed for when the provider or receiver doesn't have SAS at all.


Why can't they accept CSV files? 

Super User
Posts: 13,293

Re: SAS conversion tool

Posted in reply to mmccarver

You might see if you can find a version of DBMS Copy. We used to use that for file conversion to SAS from a number of file formats.


I'm not sure about  XPT as output but I'd be surprised if it isn't there.

Super User
Posts: 5,849

Re: SAS conversion tool

Posted in reply to mmccarver
This issue have been raised several times on the community, try a search.
I recall that since this is standard file format for clinical trial data the xpt format is kinda public and there are probably some 3rd party conversion tools out there.
Data never sleeps
Valued Guide
Posts: 505

Re: SAS conversion tool

SAS conversion tool

You should be able to cut and paste this code into the
SAS IML/R interface

inspired by

Here is a pure R solution. Should also be possible
in Python or Perl.

WORKS BEST WITH THE 1980 SAS Old text editor

HAVE d:/csv/class.csv


WANT   d:/xpt/class.xpt  (V5 export format)


 R  class  <-import("d:/csv/class.csv");
    write.xport( class, file = "d:/xpt/class.xpt" );


* create comma separated file;
dm "dexport sashelp.class 'd:/csv/class.csv' replace";

source("c:/Program Files/R/R-3.3.2/etc/",echo=T);
class  <-import("d:/csv/class.csv");
write.xport( class, file = "d:/xpt/class.xpt" );

libname xpt xport "d:/xpt/class.xpt";
data classxpt;
   set xpt.class;

proc print data=classxpt width=min;
title "from SAS proc print";

* check the xpt file;
247   libname xpt xport "d:/xpt/class.xpt";
NOTE: Libref XPT was successfully assigned as follows:
      Engine:        XPORT
      Physical Name: d:\xpt\class.xpt
248   data classxpt;
249      set xpt.class;
250   run;

NOTE: There were 19 observations read from the data set XPT.CLASS.
NOTE: The data set WORK.CLASSXPT has 19 observations and 5 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds

250 !     quit;
251   proc print data=classxpt width=min;
252   title "from SAS proc print";
253   run;

NOTE: There were 19 observations read from the data set WORK.CLASSXPT.
NOTE: PROCEDURE PRINT used (Total process time):
      real time           0.06 seconds
      cpu time            0.04 seconds

253 !     quit;

Super User
Posts: 23,237

Re: SAS conversion tool

Posted in reply to rogerjdeangelis

Summary of @rogerjdeangelis code, there's an R package that's available,


I have recollections of seeing issues with this package on StackOverflow so I would suggest searching to see how reliable this is, in addition to your own testing of course.

Super User
Posts: 23,237

Re: SAS conversion tool

Posted in reply to mmccarver

StatTransfer is a commonly referenced tool and likely the cheapest option. Other options are a SAS license, talk to SAS regarding costs.



Valued Guide
Posts: 505

Re: SAS conversion tool

For the current documentation for the R package SASxport see


For bugs see


There are two outstanding issues. 


Note R, Python and Perl can read sas7bdats


WPS and SAS can create SAS datasets from R dataframes.

The express verison of WPS does not limit the size of SAS datasets created from R.


Evan Miller and Hadley Wickham have an experimnetal R package that can create SAS datasets.

However it has acknowledged bugs which are documented and under development.

It is not usable yet.


I think Matt Shotwell is working on a Java API to SAS datasets?


I have used StatTransfer and it works well. There is also Carolina software, which uses JDBC? I have not used it.


Ask a Question
Discussion stats
  • 7 replies
  • 6 in conversation