1 Star 1 Fork 7

连享会/nwcommands

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
nwvalidvars.ado 1.21 KB
一键复制 编辑 原始数据 按行查看 历史
ThomasGrund 提交于 2015-09-18 19:13 . v1.5.1
*! 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
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/arlionn/nwcommands.git
git@gitee.com:arlionn/nwcommands.git
arlionn
nwcommands
nwcommands
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385