Skip to content

Generate series for each

In the app: Help → Help contents, Generate series for each.

Data > Generate series makes one series from a formula; fill in For each and it makes one for each of several series. For each takes names (gdp cons inv), wildcards (sa, ip: * any run of characters, ? one character) or both; in a dataset's window, pick series in the series list and press Generate for each. Series and Formula are then templates: {x} is each series, so {x}g with 100d(log({x})) makes gdp_g = 100d(log(gdp)) and so on, and {1}, {2}... are the parts the wildcards matched, so ip* with {1}_growth turns ip_us into us_growth (each * takes as much as it can, left first). {{ and }} are literal braces. The preview lists every new series and its formula before anything is made, and flags names that are not valid, formulas that do not parse or use series the dataset lacks, names made twice, and series that exist already: tick Replace to overwrite them, as for a single series. Keep updated makes them derived series. The step records the expansion as one ordinary call listing every new series, data = data.with_series(gdp_g="100d(log(gdp))", cons_g=...), or derive with Keep updated, so the script says exactly what was made and replays the same whatever series are added later; reopening the step shows the templates again. In Python, data.with_each("gdp cons inv", "{x}_g", "100d(log({x}))") does the same and is recorded the same way, and pymetrix.data.each.preview_each shows the rows. On a panel each series is computed within each entity, as for any formula.

See also