% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/survey-collection.R
\name{set_collection_if_missing_var}
\alias{set_collection_if_missing_var}
\title{Set the Missing-Variable Behaviour on a \code{survey_collection}}
\usage{
set_collection_if_missing_var(x, if_missing_var)
}
\arguments{
\item{x}{A \link{survey_collection}.}

\item{if_missing_var}{Character(1), one of \code{c("error", "skip")}.
When \code{"skip"}, member surveys missing a requested variable are
dropped from the dispatched result; when \code{"error"}, the dispatcher
aborts.}
}
\value{
The modified \code{survey_collection}, invisibly.
}
\description{
Updates the \verb{@if_missing_var} property of a \code{survey_collection}. The
new value is the per-call default \code{.dispatch_over_collection()} uses
when an analysis function (\code{get_means()}, \code{get_freqs()}, etc.) is
dispatched across the collection without an explicit per-call
\code{.if_missing_var}.
}
\details{
Setting the same value as the existing \verb{@if_missing_var} returns the
collection unchanged (no error, no warning). All other invariants on
the collection (\verb{@surveys}, \verb{@groups}, \verb{@id}) are preserved.

Pipes naturally with the rest of the collection API:
\preformatted{coll |> set_collection_if_missing_var("skip") |> get_means(y1)}
}
\examples{
d1 <- as_survey(gss_2024, ids = vpsu, weights = wtssps,
                strata = vstrat, nest = TRUE)
coll <- as_survey_collection(a = d1)
coll <- set_collection_if_missing_var(coll, "skip")
coll@if_missing_var

}
\seealso{
Other collections: 
\code{\link{add_survey}()},
\code{\link{as_survey_collection}()},
\code{\link{remove_survey}()},
\code{\link{set_collection_id}()},
\code{\link{survey_collection}()}
}
\concept{collections}
