forvar: apply a function to each of a list of variables

Description Usage Arguments Value Examples

Description

apply a function to each of a list of variables

Usage

1
forvar(varlist, action, macro = "%var")

Arguments

varlist

a list of variables in the format "var1 var2 var3" (or, if a single variable, it may be unquoted).

action

a quoted expression (must be quoted) to apply to each variable where the variable is represented in the expression by macro.

macro

an expression that will be replaced in action for each variable, by default %var.

Value

returns NULL, invisibly

Examples

1
2
3
use(cars, clear=TRUE)
forvar("speed dist", "gen(%var2, %var^2)")
listif()

genvar documentation built on Jan. 21, 2020, 9:07 a.m.