代码拉取完成,页面将自动刷新
同步操作将从 连享会/nwcommands 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
*! Date : 3sept2014
*! Version : 1.0
*! Author : Thomas Grund, Linkoping University
*! Email : contact@nwcommands.org
capture program drop nwsave
program nwsave
syntax anything [, old * format(string)]
local webname = subinstr("`anything'", ".dta","",.)
_nwsyntax _all, max(99999)
local nets : word count `netname'
if "`format'" == "" {
local format = "edgelist"
}
if (`=`nodes_all' + 20' > c(max_k_theory)){
local format = "edgelist"
}
_opts_oneof "matrix edgelist" "format" "`format'" 6556
preserve
qui {
local nodes = 0
local i = 1
tempfile attributes
capture rename _modeid modeid
capture drop _*
gen _running = _n
foreach onenet in `netname' {
nwname `onenet'
local varstodelete "`r(vars)'"
foreach onevar in `varstodelete' {
capture drop `onevar'
capture drop _nodelab
capture drop _nodevar
capture drop _nodeid
}
}
save`old' `attributes', replace
if "`format'" == "edgelist" {
clear
gen _fromid = .
gen _toid = .
tempfile edgelist_all
save `edgelist_all'
foreach onenet in `netname' {
tempfile edgelist_`onenet'
nwtoedge `onenet'
rename `onenet' _`onenet'
save `edgelist_`onenet'', replace
merge m:m _fromid _toid using `edgelist_all', nogenerate
save `edgelist_all', replace
}
}
if "`format'" == "matrix" {
local vars_required = 30
foreach onenet in `netname' {
nwname `onenet'
local vars_required = `vars_required' + `r(nodes)' + 5
}
if c(max_k_theory) < `vars_required' {
noi di "{err}You need to increase the maximum number of variables to `vars_required' with {bf:set maxvar `vars_required'}.{txt}"
exit
}
clear
local i = 1
foreach onenet in `netname' {
nwname `onenet'
local vars "`r(vars)'"
nwload `onenet'
capture drop _nodelab _nodevar _nodeid
local j = 1
foreach v of varlist `vars' {
rename `v' _net`i'_`j'
local j = `j' + 1
}
local i = `i' + 1
}
}
gen _format = ""
gen _nets = .
gen _name = ""
gen _size = .
gen _directed = ""
gen _edgelabs = ""
local i = 1
local n = _N
if `n' < `nets'{
set obs `nets'
}
foreach onenet in `netname' {
nwname `onenet'
replace _name = "`r(name)'" in `i'
local nodes = `r(nodes)'
replace _size = `nodes' in `i'
replace _directed = "`r(directed)'" in `i'
replace _edgelabs = `"`r(edgelabs)'"' in `i'
nwload `onenet', labelonly
rename _nodelab _newlabel`i'
rename _nodevar _newvar`i'
local i = `i' + 1
}
local i = 1
foreach onenet in `netname' {
rename _newlabel`i' _nodelab`i'
rename _newvar`i' _nodevar`i'
gen _runningnumber = _n
tostring _runningnumber, replace
replace _nodevar`i' = "_net`i'_" + _runningnumber
drop _runningnumber
local i = `i' + 1
}
if "`format'" == "matrix" {
replace _format = "matrix" in 1
}
if "`format'" == "edgelist" {
replace _format = "edgelist" in 1
}
replace _nets = `nets' in 1
order _format _nets _name _size _directed _edgelabs _nodevar* _nodelab*
gen _running = _n
qui merge m:m _running using `attributes', nogenerate
drop _running
}
save`old' `webname'.dta, `options'
restore
end
*! v1.5.0 __ 17 Sep 2015 __ 13:09:53
*! v1.5.1 __ 17 Sep 2015 __ 14:54:23
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。