*! version 5.0.0 15fev2020

Map

map -- maps all the unique levels of a variable or list of variables to values specified in a dictionary list.

Syntax

map varlist,
dictionary(frame)
[values(varname)]

Description

The map command maps all the unique levels of a variable or list of variables (the keys)
to their associated values (the values).
A dictionary list lists and pairs the keys and values together.
This dictionary can be specified in any frame other than the active one.

Some general remarks:

- All the keys must be unique but multiple keys can be paired with the same values.

- All the variables to match should be either strings or integers.

General options

dictionary(frame): specifies the frame containing the dictionary. This option is required.

values(varname): selects the variable in the dictionary frame containing the values to be returned. dict automatically detects this variable if all variables in the dictionary except one are used as keys.
Specify this option only if that is not the case.

Example

Consider the database:

id geo time value

1 AT 2017 0.72
2 AT 2018 0.73
3 AT 2019 0.74
4 BE 2017 0.63
5 BE 2018 0.65
6 BE 2019 0.65
7 DE 2017 0.75
8 DE 2018 0.76
9 DE 2019 0.77
. . . .
45 UK 2019 0.75

And the following dictionary in frame country_list:

geo name

AT Austria
BE Belgium
DE Germany
. .
UK United Kingdom

map geo, dictionary(country_list)

id geo name time value

1 AT Austria 2017 0.72
2 AT Austria 2018 0.73
3 AT Austria 2019 0.74
4 BE Belgium 2017 0.63
5 BE Belgium 2018 0.65
6 BE Belgium 2019 0.65
7 DE Germany 2017 0.75
8 DE Germany 2018 0.76
9 DE Germany 2019 0.77
. . . . .
45 UK United Kingdom 2019 0.75

Author

Daniel Alves Fernandes

European University Institute

daniel.fernandes@eui.eu