-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsiman.ado
83 lines (74 loc) · 2.11 KB
/
siman.ado
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
*! version 0.11.1 21oct2024
*! Type -siman which- to see versions of siman's subprograms
* version 0.10 25jul2024 IW parsing doesn't break -siman cms se- or -siman anal,repl-
* version 0.9 14jun2024 IW remove reshape
* version 0.3 08aug2023 EMZ allow analyze spelling
* version 0.2 27mar2023
* version 0.1 28nov2022
program define siman
/*
adapted from network.ado
IW 17sep2019
*/
version 13
gettoken subcmd 0 : 0, parse(" ,")
if "`subcmd'"=="cms" local subcmd comparemethodsscatter
syntax [anything] [if] [in], [which *]
// LOAD SAVED SIMAN PARAMETERS
foreach thing in `_dta[siman_allthings]' {
local `thing' : char _dta[siman_`thing']
}
// Known siman subcommands
* subcmds requiring data not to be set
local subcmds0 setup
* subcmds requiring data to be set
local subcmds1 describe analyse analyze table lollyplot zipplot comparemethodsscatter blandaltman swarm scatter nestloop
* subcmds not minding whether data are set
local subcmds2
* all known subcommands
local subcmds `subcmds0' `subcmds1' `subcmds'
// check a subcommand is given
if mi("`subcmd'") {
di as error "Syntax: siman <subcommand>"
exit 198
}
// "which" option
if inlist("`subcmd'", "which", "whic", "whi") {
which siman
foreach subcmd of local subcmds {
if "`subcmd'"=="analyze" continue
cap noi which siman_`subcmd'
}
exit
}
// Identify abbreviations of known subcommands
if length("`subcmd'")>=3 {
foreach thing in `subcmds' {
if strpos("`thing'","`subcmd'")==1 {
local subcmd `thing'
local knowncmd 1
}
}
}
* Allow analyze spelling
if "`subcmd'" == "analyze" local subcmd "analyse"
// Check it's a valid subcommand
cap which siman_`subcmd'
if _rc {
di as error "`subcmd' is not a valid siman subcommand"
if length("`subcmd'")<3 di as error "Minimum abbreviation length is 3"
exit 198
}
// For known commands, check data correctly unset/set
local type0 : list subcmd in subcmds0
if `type0' & !mi("`allthings'") {
di as error "Data are already in siman format"
exit 459
}
local type1 : list subcmd in subcmds1
if `type1' & mi("`allthings'") {
di as error "Data are not in siman format: use siman setup"
exit 459
}
siman_`subcmd' `0'
end