02-06-2017 02:57 PM
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?
02-06-2017 03:21 PM
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?
02-06-2017 03:47 PM
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.
02-06-2017 04:13 PM
02-06-2017 05:09 PM
SAS conversion tool You should be able to cut and paste this code into the SAS IML/R interface inspired by https://goo.gl/RGB2KK https://communities.sas.com/t5/Base-SAS-Programming/SAS-conversion-tool/m-p/330292 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 ====================== NAME,SEX,AGE,HEIGHT,WEIGHT Alfred,M,14,69,112.5 Alice,F,13,56.5,84 Barbara,F,13,65.3,98 Carol,F,14,62.8,102.5 Henry,M,14,63.5,102.5 James,M,12,57.3,83 Jane,F,12,59.8,84.5 Janet,F,15,62.5,112.5 Jeffrey,M,13,62.5,84 John,M,12,59,99.5 Joyce,F,11,51.3,50.5 Judy,F,14,64.3,90 Louise,F,12,56.3,77 Mary,F,15,66.5,112 Philip,M,16,72,150 Robert,M,12,64.8,128 Ronald,M,15,67,133 Thomas,M,11,57.5,85 William,M,15,66.5,112 WANT d:/xpt/class.xpt (V5 export format) ==== WORKING CODE ============ R class <-import("d:/csv/class.csv"); write.xport( class, file = "d:/xpt/class.xpt" ); FULL SOLUTION ============= * create comma separated file; dm "dexport sashelp.class 'd:/csv/class.csv' replace"; %utl_submit_r64(' source("c:/Program Files/R/R-3.3.2/etc/Rprofile.site",echo=T); library(SASxport); library(rio); 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; run;quit; proc print data=classxpt width=min; title "from SAS proc print"; run;quit; * 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;
02-06-2017 05:19 PM
Summary of @rogerjdeangelis code, there's an R package that's available, https://cran.r-project.org/web/packages/SASxport/SASxport.pdf
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.
02-06-2017 04:41 PM
StatTransfer is a commonly referenced tool and likely the cheapest option. Other options are a SAS license, talk to SAS regarding costs.
02-06-2017 06:47 PM
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.