1 Star 1 Fork 7

连享会/nwcommands

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
nwsort.ado 1.18 KB
一键复制 编辑 原始数据 按行查看 历史
ThomasGrund 提交于 2015-09-18 19:13 . v1.5.1
*! Date : 5feb2015
*! Author : Thomas Grund, Linkoping University
*! Email : contact@nwcommands.org
capture program drop nwsort
program nwsort
version 9.0
syntax [anything(name=netname)], by(varlist) [ ATTributes(varlist) xvars stable ]
local attribute_full `attributes' `by'
local attribute : list uniq attribute_full
_nwsyntax `netname', max(1)
local id = `id'
preserve
qui nwload `netname', labelonly
qui drop if _n > `nodes'
qui gen _running = _n
qui if "`attribute'" != "" {
putmata `attribute', replace
}
sort `by', `stable'
putmata permutationVec = _running, replace
qui nwname `netname', newlabsfromvar(_nodelab)
restore
mata: nw_mata`id' = nw_mata`id'[permutationVec,permutationVec]
foreach oneatt in `attribute' {
capture confirm numeric variable `oneatt'
mata: `oneatt' = `oneatt'[permutationVec]
if _rc == 0 {
mata: st_store((1::`nodes'),"`oneatt'", `oneatt')
}
else {
mata: st_sstore((1::`nodes'),"`oneatt'", `oneatt')
}
capture mata: mata drop `oneatt'
}
if "`xvars'" == "" {
nwload `netname'
}
capture mata: mata drop permutationVec
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