exporting labelled non-integers to Stata

I've posted an issue here, too:

When a labelled variable has non-integer values, exporting to Stata runs into an error that: "Stata only supports labelled integers". However, this does not seem to be the case. Something like the code below:

labelled_spss(c(1.1, 1:10), c(Good = 1, Bad = 8), na_range = c(9, Inf),
    label = "Quality rating")

can be seen in Stata (via SPSS, then converted to Stata via StatTransfer) as:

                  type:  numeric (float)
                 label:  x, but 7 nonmissing values are not labeled

                 range:  [1,8]                        units:  .1
         unique values:  9                        missing .:  2/11

            tabulation:  Freq.   Numeric  Label
                             1         1  good
                             1       1.1  
                             1         2  
                             1         3  
                             1         4  
                             1         5  
                             1         6  
                             1         7  
                             1         8  bad
                             2         .

In the end, is it Stata's fault or am I misunderstanding what is going on?

I don't work with Stata, but thought these pieces of info might be relevant. From the NEWS for haven for the most recent (2.1.0) release:

write_dta() now checks that the labelled values are integers, not the values themselves (#401).

And from an earlier (1.1.2) release:

write_dta() allows non-ASCII variable labels for version 14 and above (#383). It also uses a less strict check for integers so that a labelled double containing only integer values can written (#343).

1 Like

Thanks Mara, that is great.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.