0

when I write my sav file into csv (using library(haven), read_sav and write.csv), it can export to csv file properly, but some of the text in my header is missing. For example, each header has a question number with some subtext describing the question in detail. After I write the data to csv the question number is still on the header, but the description is missing.

Phil
  • 7,287
  • 3
  • 36
  • 66
sky0215
  • 29
  • 5
  • 3
    That‘s because the haven package can deal with and show the variable labels from .sav files, same with value labels. haven stores this as attributes for each column. A csv can‘t, so when exporting, this info just gets lost/deleted. – deschen Aug 21 '21 at 06:02
  • 1
    You should probably check the package `labelled`. It has some better ways of setting/extracting SPSSlike variable and value labels. E.g. with `var_label(YOUR DATA FRAME HERE)` you get all variable labels of your data. – deschen Aug 23 '21 at 21:03
  • Thank you!! The labelled package and `var_label()`worked. I used `read_spss()` , `var_label()`, and `write.csv()` to export the variable labels in the .csv format. – sky0215 Aug 25 '21 at 03:12

0 Answers0