Title

randid - Generate a random id from a meaningful one

Syntax

randid newvar = varelist [, range(min [max]) xwalk(path)]

Description

randid creates newvar, containing a unique random value for each unique combination of varelist.
In other words, it creates an anonymous ID variable. newvar will always contain integers.

varelist can contain numeric or string variables, but not both.

Options

range() can specify the minimum and maximum values for the new ID variable. If range() is not specified, the IDs will be numbered consecutively from 1. If range() is specified as min only,
newid will range from the specified number, up to the the largest number with the same number of digits. E.g., if range(100) (or range(352)) is specified, IDs will be generated from there up to 999.

xwalk(path) will save a crosswalk between old and new IDs in the file specified by path. Note that the file will be overwritten if it already exists.