代码拉取完成,页面将自动刷新
*! Date : 24aug2014
*! Version : 1.0
*! Author : Thomas Grund, Linkoping University
*! Email : contact@nwcommands.org
capture program drop nwvalidvars
program nwvalidvars
syntax anything(name=nodes), stub(string)
mata: st_rclear()
// Generate temporary varlist and check for each variable if it already exists.
local varlist = ""
local invalid = 0
forvalues i=1/`nodes' {
local varlist "`varlist' `stub'`i'"
capture confirm variable `stub'`i'
if !_rc {
local invalid = `invalid' + 1
}
}
mata: st_global("r(valid)", "true")
mata: st_global("r(stub)", "`stub'")
// Find valid Stata variable names to store network.
if `invalid' > 0 {
mata: st_global("r(valid)", "false")
local stub_add = 0
while `invalid' > 0 {
local varlist = ""
local stub_add = `stub_add' + 1
local invalid = 0
forvalues i=1/`nodes' {
local varlist "`varlist' `stub'`stub_add'_`i'"
capture confirm variable `stub'`stub_add'_`i'
if !_rc {
local invalid = `invalid' + 1
}
}
}
}
global validvars "`varlist'"
mata: st_global("r(validvars)", "`varlist'")
end
*! v1.5.0 __ 17 Sep 2015 __ 13:09:53
*! v1.5.1 __ 17 Sep 2015 __ 14:54:23
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。