help addbefore

Title

addbefore -- Add number or character before a variable

Syntax

addbefore varlist , [options]

where varlist is a list of non-string variables, or _all. The * and ? wildcards are also allowed in varlist.

Description

addbefore can add number or character before a variable, and you can set the digits of the variable as well.

Options for addbefore

generate(newvarlist) specifies the new variable(s) that will receive the values. If it is specified, then newvarlist
must have exactly as many variables as there are in varlist; the variable names in the both lists will be presented in same order.

replace specifies that the new values are to be replaced directly in the variables of varlist. Under this option, addbefore functions as a replace operation.
You must use either gen() or replace, but not both.

digits(integer) specifies the digits of the variables. You must specify an integer less than 10, in general, it can basically according to the needs of user.

char(str) specifies a character that adds before the variables. For stata13, the length of character must be 1, so it can not be a Chinese character. For stata14 and stata15, character represents a unicode character, and the
number of unicode character must be 1, so it can be a Chinese character. For numeric variable, you must specify the numbers 0 to 9.

Example

Use the command input read in the data

`"clear"'

`"set more off"'

`"input str15 v1 v2 v3 str15 v4"'

`"a 1 22 a"'

`"dd2 56555 666 dd2"'

`"2 22 55 2"'

`"65 66 228 65"'

`"889 22 33 889"'

`"525 55 889 525"'

`"end"'

Add a value before v1 v2 v3 v4 , digit is 7. By default, the character is 0.

`"addbefore v1 v2 v3 v4 , digits(7) gen(v5 v6 v7 v8)"'

Add a value before v2 v3 , digit is 7, and specify the character as 1.

`"addbefore v2 v3 , d(7) c(1) replace "'

Add a value before v1 v4 , digit is 7, and specify the character as a.

`"addbefore v1 v4 , d(7) c(a) replace "'

Author

Haitao SI

China Stata Club(爬虫俱乐部)

Wuhan, China

sht_finance@foxmail.com

Yuan XUE

China Stata Club(爬虫俱乐部)

Wuhan, China

xueyuan19920310@163.com

Muhammad Usman

Zhongnan University of Economics and Law

Wuhan, China

usmanzuel@yahoo.com