Skip to content

Commit b2b170e

Browse files
committed
Expand documentation for write_dta version argument. Close #721
1 parent f947e9d commit b2b170e

File tree

2 files changed

+62
-2
lines changed

2 files changed

+62
-2
lines changed

R/haven-stata.R

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,34 @@
2121
#' For Stata 14 and later, you should not need to manually specify `encoding`
2222
#' value unless the value was incorrectly recorded in the source file.
2323
#'
24+
#' @section Stata versions:
25+
#' The `version` argument controls which Stata file format is used, which
26+
#' determines compatibility with different versions and flavours of Stata.
27+
#' The following table shows the supported versions:
28+
#'
29+
#' \tabular{llll}{
30+
#' \strong{version} \tab \strong{File format} \tab \strong{Stata version} \tab \strong{Compatible flavours} \cr
31+
#' 8-9 \tab 113 \tab Stata 8-9 \tab BE, SE, MP \cr
32+
#' 10-11 \tab 114 \tab Stata 10-11 \tab BE, SE, MP \cr
33+
#' 12 \tab 115 \tab Stata 12 \tab BE, SE, MP \cr
34+
#' 13 \tab 117 \tab Stata 13 \tab BE, SE, MP \cr
35+
#' 14 \tab 118 \tab Stata 14+ \tab BE, SE, MP \cr
36+
#' 15 \tab 119 \tab Stata 15+ \tab MP only
37+
#' }
38+
#'
39+
#' In most cases you should use the default `version = 14`:
40+
#' \itemize{
41+
#' \item Versions 8-14 create files readable by all flavours of Stata
42+
#' (Stata/BE, Stata/SE, and Stata/MP).
43+
#' \item Version 15 creates format 119 files, designed for datasets exceeding
44+
#' 32,767 variables. These files can only be opened by Stata/MP, even if
45+
#' your dataset has fewer variables. Stata/BE and Stata/SE will refuse to
46+
#' open these files with an error like "dataset too large".
47+
#' }
48+
#'
49+
#' Only use `version = 15` if you need to write a dataset with more than 32,767
50+
#' variables and your recipients have access to Stata/MP.
51+
#'
2452
#' @inheritParams readr::datasource
2553
#' @inheritParams read_spss
2654
#' @param encoding The character encoding used for the file. Generally,
@@ -68,7 +96,8 @@ read_stata <- read_dta
6896

6997
#' @export
7098
#' @rdname read_dta
71-
#' @param version File version to use. Supports versions 8-15.
99+
#' @param version File version to use. Supports versions 8-15. See the
100+
#' "Stata versions" section below for details on compatibility.
72101
#' @param label Dataset label to use, or `NULL`. Defaults to the value stored in
73102
#' the "label" attribute of `data`. Must be <= 80 characters.
74103
#' @param strl_threshold Any character vectors with a maximum length greater

man/read_dta.Rd

Lines changed: 32 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)