-------------------------------------------------------------------------------
help for nsplit                                                   manual:  none
-------------------------------------------------------------------------------

Split numeric variables with integer values into new smaller numeric variables.

nsplit [varname] [if exp] [in range] , digits(digit pattern in existing variable) [generate(newvarlist or stub) ]

Description

nsplit creates however many new numeric variables it takes to split a numeric variable into digit pattern.

Options

digits(digit pattern in existing variable) describes the pattern in the existing numeric variable. If it is a repeated pattern then you only need to supply the number of digits the new variables should contain. For example:

. nsplit id, digits(2)

for an id variable with 6 digits is equivalent to:

. nsplit id, digits(2 2 2)

generate(newvarlist or stub) states what you want the new variable names to be. If only one name is listed then that will be the first characters of the new variable names: stub1 stub2 etc. If no new variable name is used, then the original variable name will be used as the stub.

Examples

. nsplit id, digits(2 3)

. list id*

id id1 id2

12345 12 345

2305 2 305

2003 2 3

. nsplit date, digits(2) generate(month year)

. list date month year

date month year

1294 12 94

588 5 88

Author

Dan Blanchette The Carolina Population Center University of North Carolina - Chapel Hill, USA dan_blanchette@unc.edu

Acknowledgements

Many suggestions were implemented that were made by:

Nicholas J. Cox, University of Durham, U.K.

Also see

On-line: split, mod(), int(), dexfcns