egen是Stata中非常实用的一个命令,由于包含大量可以连用的函数,功能非常强大。这里做一个总结,把曾经使用过的功能进行一个记录。
help 原文如下
concat(varlist) [, format(%fmt) decode maxlength(#) punct(pchars)]
may not be combined with by. It concatenates varlist to produce a string variable. Values of string
variables are unchanged. Values of numeric variables are converted to string, as is, or are converted
using a numeric format under the format(%fmt) option or decoded under the decode option, in which case
maxlength() may also be used to control the maximum label length used. By default, variables are added
end to end: punct(pchars) may be used to specify punctuation, such as a space, punct(" "), or a comma,
punct(,).
应用示例
clear
inp str5 var1 var2
ASDS 2.334
SDDF 0.434
WESF 43.45
WSFS 3.455
end
egen var3=concat(var1 var2) //help egen ;concat合并变量的命令
代码执行后的效果