File: highlight.do.fold

package info (click to toggle)
kf6-syntax-highlighting 6.13.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 47,568 kB
  • sloc: xml: 197,750; cpp: 12,850; python: 3,023; sh: 955; perl: 546; ruby: 488; pascal: 393; javascript: 161; php: 150; jsp: 132; lisp: 131; haskell: 124; ada: 119; ansic: 107; makefile: 96; f90: 94; ml: 85; cobol: 81; yacc: 71; csh: 62; erlang: 54; sql: 51; java: 47; objc: 37; awk: 31; asm: 30; tcl: 29; fortran: 18; cs: 10
file content (89 lines) | stat: -rw-r--r-- 4,279 bytes parent folder | download | duplicates (6)
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
84
85
86
87
88
89
<beginfold id='1'>/*</beginfold id='1'> Test file for kate's stata syntax highlighting
<endfold id='1'>*/</endfold id='1'>
*! version 1.2.0 2mar2003 E. Leuven
program define spellsplit
        version 7
        syntax [anything], spell(varlist min=2 max=2) [ by(varlist)]
        tokenize `spell'
        local date0 `1'
        local date1 `2'
        local f0 : format `date0'
        local f1 : format `date1'

        <beginfold id='1'>/*</beginfold id='1'> set default statistic <endfold id='1'>*/</endfold id='1'>
        local current "mean"

        gettoken left anything : anything, match(prns)
        while "`left'"!="" <beginfold id='2'>{</beginfold id='2'>
                if "`prns'"!="" <beginfold id='2'>{</beginfold id='2'>
                        if !inlist("`left'","mean","sum") <beginfold id='2'>{</beginfold id='2'>
                                di as error "Statistic `left' not supported"
                                exit 198
                        <endfold id='2'>}</endfold id='2'>
                        local current "`left'"
                <endfold id='2'>}</endfold id='2'>
                else <beginfold id='2'>{</beginfold id='2'>
                        local `current'vars  ``current'vars' `left'
                <endfold id='2'>}</endfold id='2'>
                gettoken left anything : anything, match(prns)
        <endfold id='2'>}</endfold id='2'>
        if ("`meanvars'"!="") <beginfold id='2'>{</beginfold id='2'>
                confirm var `meanvars'
                unab meanvars : `meanvars'
        <endfold id='2'>}</endfold id='2'>
        if ("`sumvars'"!="") <beginfold id='2'>{</beginfold id='2'>
                confirm var `sumvars'
                unab sumvars : `sumvars'
        <endfold id='2'>}</endfold id='2'>

        quietly <beginfold id='2'>{</beginfold id='2'>
                g _count = 1
                local xvars `meanvars' `sumvars' _count

                <beginfold id='1'>/*</beginfold id='1'> create dummy by-var if no by option is specified <endfold id='1'>*/</endfold id='1'>
                if "`by'"=="" <beginfold id='2'>{</beginfold id='2'>
                        tempvar by
                        g byte `by' = 1
                <endfold id='2'>}</endfold id='2'>
                tempvar `xvars' `by'

                <beginfold id='1'>/*</beginfold id='1'> create negative for subtraction when spell ends <endfold id='1'>*/</endfold id='1'>
                cap foreach v of varlist `xvars' <beginfold id='2'>{</beginfold id='2'>
                        g double ``v'' = -`v'
                        local txvars `txvars' ``v''
                <endfold id='2'>}</endfold id='2'>
                cap foreach v of varlist `by' <beginfold id='2'>{</beginfold id='2'>
                        g double ``v'' = `v'
                        local txvars `txvars' ``v''
                <endfold id='2'>}</endfold id='2'>

                stack `date0' `xvars' `by' `date1' `txvars', into(`date0' `xvars' `by') clear

                <beginfold id='1'>/*</beginfold id='1'> calculate totals per date <endfold id='1'>*/</endfold id='1'>
                cap foreach v of varlist `xvars' <beginfold id='2'>{</beginfold id='2'>
                        egen double ``v'' = sum(`v'), by(`by' `date0')
                <endfold id='2'>}</endfold id='2'>

                <beginfold id='1'>/*</beginfold id='1'> unique dates only <endfold id='1'>*/</endfold id='1'>
                by `by' `date0', sort: keep if _n==1

                <beginfold id='1'>/*</beginfold id='1'> calculate totals (+ when spell starts - when ends) <endfold id='1'>*/</endfold id='1'>
                sort `by'
                cap foreach v of varlist `xvars' <beginfold id='2'>{</beginfold id='2'>
                        by `by': replace `v' = sum(``v'')
                <endfold id='2'>}</endfold id='2'>
                by `by': g `date1' = `date0'[_n + 1]

                drop if `date0'>`date1'
                drop _stack
                drop if _count==0
                order `by' `date0' `date1' `xvars'
                format `date0' `f0'
                format `date1' `f1'

                cap for var `meanvars': replace X = X/_count

                compress
        <endfold id='2'>}</endfold id='2'>

end