*! version 1.0.0 23Sep2018

Title

genidseq -- Generates numeric sequence to represent long identifiers

Syntax

genidseq
ID-varname
,
generate(newvarname)
[ start(#)
increment(#)
nosort ]

* generate(newvarname) generate newvar to represent ID-varname

start(#) set starting value for the sequence; default is 1

increment(#) set increment value for the sequence; default is 1

nosort do not sort the data by ID-varname; default is to sort by ID-varname

* generate(newvarname) is required.

Description

genidseq generates a numeric sequence of values to better represent an existing identifier variable that may be too long to be visually helpful (this is
typical in health care data where patient identifiers are purposely generated to be long and scrambled). The new ID sequence can be specified to start at any integer
value and increase in any integer increment (with the default to start at 1 and increase in an increment of 1).

Examples

Assume the following existing identifier:

patientID
---------------
259000401100365
259000401100365
259000401100365
260000407995214
260000407995214
260000407995214
271000408055062
271000408055062
271000408055062
301000408997734
301000408997734
301000408997734
330000411484007
330000411484007
330000411484007
259504413317405
259504413317405
259504413317405

Typing:

. genidseq patientID, gen(id)

will produce:

patientID id
--------------- ---
259000401100365 1
259000401100365 1
259000401100365 1
260000407995214 2
260000407995214 2
260000407995214 2
271000408055062 3
271000408055062 3
271000408055062 3
301000408997734 4
301000408997734 4
301000408997734 4
330000411484007 5
330000411484007 5
330000411484007 5
259504413317405 6
259504413317405 6
259504413317405 6

while typing:

. genidseq patientID, gen(id) start(10) incr(10)

will produce:

patientID id
--------------- ---
259000401100365 10
259000401100365 10
259000401100365 10
260000407995214 20
260000407995214 20
260000407995214 20
271000408055062 30
271000408055062 30
271000408055062 30
301000408997734 40
301000408997734 40
301000408997734 40
330000411484007 50
330000411484007 50
330000411484007 50
259504413317405 60
259504413317405 60
259504413317405 60

Citation of genidseq

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

Linden, Ariel (2018). genidseq: Stata module for generating a numeric sequence to represent long identifiers.

Author

Ariel Linden

President, Linden Consulting Group, LLC

alinden@lindenconsulting.org

http://www.lindenconsulting.org

Also see

Online: encode, recode