-------------------------------------------------------------------------------
help for ralpha
-------------------------------------------------------------------------------

Utility to generate pseudo-random characters or words

ralpha newvar [ , range(LowerChar/UpperChar) loweronly upperonly length(integer) ]

Description

ralpha generates a variable with pseudorandom characters/letters or words. It uses runiform to draw random numbers that are converted or assigned to a list of alpha characters ([A-Za-z]). The user can tell ralpha to select random variates from a subset of the list of alpha characters using the range option. The length option can be used to generate random words as a string variable.

Options

range specifies a subset of alpha characters [A-Za-z] from which pseudorandom characters are drawn. This option must be specified as (lowercharacter/uppercharacter). Notice that the uppercase character comes first in this range.

So to draw random characters from X to c (or X,Y,Z,a,b,c), you would include the option "range(X/c)". Omitting this option is the same as specifying "range(A/z)"

loweronly draws from the lowercase alpha characters only ([a-z]). This option cannot be used in combination with the option range; however, note that it is equivalent to specifying "range(a/z)."

upperonly draws from the uppercase alpha characters only ([A-Z]). This option cannot be used in combination with the option range; however, note that it is equivalent to specifying "range(A/Z)."

length specifies the length of the newvar of pseudorandom alpha chars. This option can be used to create words made of random letters (up to 244 characters, see limits); for instance, a random ID where the ID needs to include letters instead of numbers.

Examples

. clear . set obs 25 . ralpha loweronly . ralpha uversion, upperonly . ralpha range1, range(B/g)

// Create Random Words // . ralpha range2, range(J/z) l(10) . g newword = proper(range2)

Author

Eric A. Booth, Texas A&M University ebooth@ppri.tamu.edu http://www.eric-a-booth.com

Also see

On-line: help for random numbers; string functions; set seed; setrngseed (if installed)