📄 egen.ado
字号:
*! version 3.3.3 01oct2004
program define egen, byable(onecall) sortpreserve
version 6, missing
gettoken type 0 : 0, parse(" =(")
gettoken name 0 : 0, parse(" =(")
if `"`name'"'=="=" {
local name `"`type'"'
local type : set type
}
else {
gettoken eqsign 0 : 0, parse(" =(")
if `"`eqsign'"' != "=" {
error 198
}
}
confirm new variable `name'
gettoken fcn 0 : 0, parse(" =(")
gettoken args 0 : 0, parse(" ,") match(par)
if `"`par'"' != "(" {
exit 198
}
if `"`args'"' == "_all" {
version 7.0, missing
unab args : _all
local args : subinstr local args "`_sortindex'" "", all word
version 6.0, missing
}
syntax [if] [in] [, *]
if _by() {
local byopt "by(`_byvars')"
local cma ","
}
else if `"`options'"' != "" {
local cma ","
}
tempvar dummy
global EGEN_Varname `name'
capture noisily _g`fcn' `type' `dummy' = (`args') `if' `in' /*
*/ `cma' `byopt' `options'
global EGEN_Varname
if _rc { exit _rc }
quietly count if missing(`dummy')
if r(N) {
local s = cond(r(N)>1,"s","")
di in bl "(" r(N) " missing value`s' generated)"
}
rename `dummy' `name'
end
exit
/*
syntax is:
egen type varname = xxx(something) if exp in exp, options
passed to xxx is
<type> <varname> = (something) if exp in exp, options
If xxx expects varlist,
gettoken type 0 : 0
gettoken vn 0 : 0
gettoken eqs 0 : 0 /* known to be = */
syntax varlist ...
If xxx expects exp
syntax newvarname =exp ...
Note, the utility routine should not present unnecessary messages
and must return nonzero if there is a problem. The new variable
can be left created or not; it will be automatically dropped.
If the return code is zero, a count of missing values is automatically
presented.
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -