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;
... View more