1 Star 1 Fork 1

连享会/diagram

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
diagramconnection.ado 1.93 KB
一键复制 编辑 原始数据 按行查看 历史
haghish 提交于 2016-08-04 18:17 . 1.0.0
prog define diagramconnection
version 11
syntax [using/] , tempfile(str) sign(str) [indent(str)]
tempname knot
file open `knot' using "`tempfile'", write append
//check for string variable type
cap confirm string variable from
if _rc == 0 local fromisstring 1
cap confirm string variable to
if _rc == 0 local toisstring 1
forval i = 1 / `c(N)' {
local next // reset
if "`fromisstring'" != "1" & "`toisstring'" != "1" {
local next : di "`indent'" from[`i'] " `sign' " to[`i']
}
else {
// FROM
// ====
if "`fromisstring'" == "1" {
*local next : di "`indent'" `"""' "`from'" `"""' " `sign' "
if substr(from[`i'], 1,1) == `"""' {
local next : di "`indent'" from[`i'] " `sign' "
}
else local next : di "`indent'" `"""' from[`i'] `"""' " `sign' "
}
else local next : di "`indent'" from[`i'] " `sign' "
// TO
// ====
if "`toisstring'" == "1" {
if substr(to[`i'], 1,1) == `"""' {
local next : di `"`next'"' to[`i']
}
*else local next = `"`next'"' + `"""' + to[`i'] + `"""'
else local next : di `"`next'"' `"""' to[`i'] `"""'
}
else local next : di `"`next'"' to[`i']
}
file write `knot' `" `next'"'
capture confirm variable label
if _rc == 0 {
local lbl : di label[`i']
}
capture confirm variable properties
if _rc == 0 {
local prp : di properties[`i']
}
//Stata returns a weird error with combining !missing() function, which
//made me take this stupid work-around...
*if !missing(label[`i']) {
if !missing("`lbl'") {
local details `"label="`lbl'""'
//add comma
if !missing(`"`prp'"') {
local details = `"`details', "'
}
}
if !missing(`"`prp'"') {
local details = `"`details'"' + `"`prp'"'
}
if !missing(`"`details'"') {
file write `knot' `"[`details']"'
}
local details // reset
file write `knot' ";" _n
}
end
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/arlionn/diagram.git
git@gitee.com:arlionn/diagram.git
arlionn
diagram
diagram
master

搜索帮助