0

I have two large data sets in SPSS which I am trying to merge the files using R - (for test purpose I included only two variables with 4 cases) and below is the R syntax that I am using for merging the files.

data <- read.spss("D:/R_merge/Data.sav")

data1 <- read.spss("D:/R_merge/Data1.sav")

mydata <- smartbind(data, data1)

write.foreign(mydata, "D:/R_merge/data.txt", "D:/R_merge/data.sps",   package="SPSS")

The issue is: when I export the data from R to SPSS the value labels (titles) are not shown in the final merged SPSS data set - only the variable name is shown at the title. I have read the forum but there was no direct syntax provided for this issue.

hrbrmstr
  • 77,368
  • 11
  • 139
  • 205
Jagadish
  • 23
  • 3
  • I have also checked the solution provided at link: http://stackoverflow.com/questions/10181730/information-from-label-attribute-in-r-to-variable-labels-in-spss?rq=1. however, No luck – Jagadish Aug 03 '15 at 10:30
  • 1
    It would help if the question was reproducible (i.e. provide sample data files). Having said that, you could try to use `haven` - https://github.com/hadley/haven - vs `foreign` to write the data. – hrbrmstr Aug 03 '15 at 10:31
  • I tried to attach the file. however i am sure how to do it - since there is no direct option available to upload the files. – Jagadish Aug 03 '15 at 10:45
  • Right. You have to use Dropbox or Google Drive (etc) – hrbrmstr Aug 03 '15 at 13:39
  • You can use haven to write back to an actual .sav file (as opposed to using `write.foreign`), as well as read the files in initially. – Thomas Aug 28 '15 at 02:22
  • Hi Thomas: I have tried using 'haven' option to get the titles in SPSS. this seems to be work exactly the same way as i asked. however, when i am appending the 2 dataframes to 1 data frame and when I write the final merged dataframe to SPSS the titles are displayed only for the 1st dataframe and for the 2nd dataframe the codes are displayed. Here is the R code which i am using: data <- read_sav("D:/R_merge/Data.sav") data1 <- read_sav("D:/R_merge/Data1.sav") mydata <- rbind(data, data1) write_sav(data.frame(mydata), "D:/R_merge/test2.sav") So please help me in sorting this issue. – Jagadish Sep 02 '15 at 07:46
  • Also i have tried the "smartbind option but seems the option is not working ..on this method – Jagadish Sep 02 '15 at 07:51

0 Answers0