*! version 1.0.0 04Sep2019

Title

seqfind -- Finds the sequence of a numeric character within a variable list

Syntax

seqfind
newvar
[if] [in]
,
vars(varlist)
charval(#)
length(#)

Options

vars(varlist) specifies the varlist in which the sequence is to be evaluated. All variables in the varlist must be numeric, therefore string variables must be converted to numeric or encoded (see encode);
vars() is required.

charval(#) specifies the numeric character value to be evaluated; charval() is required.

length(#) specifies the length of the sequence to be evaluated. length() must be greater than 0 and less than the count of variables in vars(); length() is required.

Description

seqfind generates a newvar indicating whether a specified numeric character appears in a sequence of a specified length within a varlist.

Examples

Setup

. use seqfinddata.dta

Create a variable indicating whether the character value 1 appears in a sequence of 3 within the varlist t1 through t6.

. seqfind seq1, vars(t1-t6) char(1) len(3)

Create a variable indicating whether the character value 2 appears in a sequence of 2 within the varlist t1 through t6.

. seqfind seq2, vars(t1-t6) char(2) len(2)

Create a variable indicating whether the character value 1 appears in a sequence of 2 within the varlist t1 through t6 for age < 50.

. seqfind seq3 if age <50, vars(t1-t6) char(1) len(2)

Citation of seqfind

seqfind is not an official Stata command. It is a free contribution
to the research community, like a paper. Please cite it as such:

Linden A. (2019). SEQFIND: Stata module to find the sequence of a numeric character within a variable list

Authors

Ariel Linden

President, Linden Consulting Group, LLC

alinden@lindenconsulting.org

Also see

Help: randtreatseq (if installed)