Good day,
I'm trying to export a labeled data set to SPSS and Stata using the Haven package. When I open the data in SPSS, the labels export correctly, however, the underlying values are recoded. For example, 0 is recoded to 1.
The result that I expect is
0 = "Never [0]"
1 = "Monthly or less [1]",
2 = "2 to 4 times a month [2]",
3 = "2 to 3 times a week [3]",
4 = "4 or more times a week [4]"
However, these are the values and labels I'm getting in SPSS for SPSS and Stata datasets.
1 = "Never [0]"
2 = "Monthly or less [1]",
3 = "2 to 4 times a month [2]",
4 = "2 to 3 times a week [3]",
5 = "4 or more times a week [4]"
Here is the R code I've used:
library(Hmisc)
audit$a_audit_1_1 = factor(audit$a_audit_1_1, levels = c(0, 1, 2, 3, 4))
levels(audit$a_audit_1_1) = c(
"Never [0]",
"Monthly or less [1]",
"2 to 4 times a month [2]",
"2 to 3 times a week [3]",
"4 or more times a week [4]")
label(audit$a_audit_1_1)="How often do you..."
library(haven)
write_dta(audit, "audit.dta")
Is there a way to for Haven to keep the original codes?
Thank you very much for your help.
André