*! version 0.1.1 9 Jan 2022

mpitb ctyselect -- selects countries using the reference sheet

Syntax

mpitb ctyselect varname [if] [in] [, options]

select(ctylist) list of countries

rexp(regex) regular expression

Description

mpitb ctyselect selects one or countries from the reference sheet and returns
their country codes in r(). varname is required and directs ctyselect
to the variable containing the country codes.

ctyselect can be used to conveniently control loops for estimations or other
steps in the production process. Called without any option, ctyselect returns
all country codes found in the reference sheet.

Options

select(ctylist) allows to manually select country codes. Technically, it
simply refers to values of varname, which may be string or
numeric.

rexp(regex) allows to select country codes based on regular expressions
applied to varname.

Examples

1. Selecting all countries (as covered by the reference sheet) frame. Let the
variable ccty contain the country code

use refsheet , clear

mpitb ctyselect ccty

2. Select specific countries

mpitb ctyselect ccty , s(BGD IND UGA)

3. Select all countries with a country code starting with "I"

mpitb ctyselect ccty , r(^[I])

Stored Results

ctyselect stores the following in r():

Macros

r(ctylist) list of countries

r(Nctylist) number of countries