[R] Convert csv to xpt file in R?

Santosh santosh2005 at gmail.com
Thu May 7 22:12:08 CEST 2015


Dear Rxperts..
Thanks for your response. Below is the version on Windows 7 Enterprise
(64-bit) OS machine..Yes, I tried SASxport, foreign and Hmisc.. have used
SASxport before (not for writing to xpt though) and continue to have the
same write to sas transport file  issue..

> version
               _
platform       x86_64-w64-mingw32
arch           x86_64
os             mingw32
system         x86_64, mingw32
status
major          3
minor          0.2
year           2013
month          09
day            25
svn rev        63987
language       R
version.string R version 3.0.2 (2013-09-25)

Thanks and regards,
Santosh

On Thu, May 7, 2015 at 8:51 AM, Nordlund, Dan (DSHS/RDA) <
NordlDJ at dshs.wa.gov> wrote:

> > -----Original Message-----
> > From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Santosh
> > Sent: Wednesday, May 06, 2015 8:04 PM
> > To: r-help
> > Subject: [R] Convert csv to xpt file in R?
> >
> > Dear Rxperts..
> >
> > Was wondering if there is a way in R to read a csv file and generate an
> > XPT
> > file?  For some reason the function write.xport() does not seem to work
> > for
> > me....
> > i get the following error...
> > "error in label.data.frame(df,default=""): length of default same as x
> >
> > A sample dataframe is given below
> > xg2 <- data.frame(aa=runif(10),bb=sample(runif(100),10))
> > SASformat(xg2$aa) <- 'Numeric2'
> > SASformat(xg2$bb) <- 'Numeric2'
> > label(xg2$aa) <- "test aa"
> > label(xg2$bb) <- "test bb"
> > label(xg2) <- "testa"
> > SAStype(xg2) <- "TestXge"
> > write.xport(xg2,file="A1.xpt")
> > Error in label.data.frame(df, default = "") :
> >   length of default must same as x
> >
> >
> > Any suggestions/tips are welcome..
> >
> > Thanks and regards
> > Santosh
> >
>
> The code above runs without error and produces an xport file on my Win7
> 64-bit system running R-3.2.0.  You haven't told us anything about your OS,
> version of R, and packages loaded.  Have you tried running the code from a
> fresh start of R after only loading the SASxport package?
>
> Dan
>
> Daniel J. Nordlund
> Research and Data Analysis Division
> Services & Enterprise Support Administration
> Washington State Department of Social and Health Services
>
>
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list