Skip to contents

A convenience wrapper around nhanesA::nhanesSearchVarName that searches for variables by exact variable name match. The function automatically converts input to uppercase to match NHANES naming conventions. Use this when you know the variable code; use term_search() for text-based searches.

Usage

var_search(var)

Arguments

var

Character. Variable name to search for. Will be automatically converted to uppercase. Not case-sensitive.

Value

A character vector of CDC table names containing the variable (e.g., "DEMO", "DEMO_B", "DEMO_C"). Returns character(0) if the variable is not found.

See also

term_search for text-based searches, get_url for documentation URLs, nhanesSearchVarName for the underlying function

Other search and lookup functions: get_url(), term_search()

Examples

# \donttest{
# Search for specific variable (case-insensitive)
var_search("RIDAGEYR") # Age variable across all DEMO cycles
#>  [1] "DEMO"   "DEMO_B" "DEMO_C" "DEMO_D" "DEMO_E" "DEMO_F" "DEMO_G" "DEMO_H"
#>  [9] "DEMO_I" "DEMO_J" "DEMO_L" "P_DEMO"
var_search("BPXSY1") # Systolic blood pressure
#>  [1] "BPX"   "BPX_B" "BPX_C" "BPX_D" "BPX_E" "BPX_F" "BPX_G" "BPX_H" "BPX_I"
#> [10] "BPX_J"
# }