Skip to contents

Marks one or more variables as select-all-that-apply (SATA) in a survey design object or a data frame. Unlike the other unified setters (which map variable names to heterogeneous content), set_sata() applies a single logical flag to all listed variables, so it uses a simplified two-convention pattern.

Usage

set_sata(x, ..., variable = NULL, sata = TRUE)

Arguments

x

A survey design object or data.frame.

...

<tidy-select> Variables to mark. Supports selection helpers: tidyselect::starts_with(), tidyselect::all_of(), tidyselect::any_of(), etc. Cannot be combined with variable.

variable

character. Alternative programmatic interface: character vector of variable names. Cannot be combined with ....

sata

logical(1). TRUE (default) marks variables as SATA; FALSE removes the SATA flag. NA is not accepted.

Value

The modified object, invisibly.

Details

Convention A (tidy-select ...) — recommended:

design |> set_sata(news_tv, news_online, news_radio)
design |> set_sata(starts_with("news_"))

Convention B (variable = character vector) — programmatic:

sata_vars <- c("news_tv", "news_online", "news_radio")
design |> set_sata(variable = sata_vars)

Setting sata = FALSE unmarks the listed variables.

Examples

d <- as_survey(nhanes_2017, ids = sdmvpsu, weights = wtint2yr,
               strata = sdmvstra, nest = TRUE)
d <- set_sata(d, riagendr, ridageyr)
d <- set_sata(d, riagendr, sata = FALSE)