-
Notifications
You must be signed in to change notification settings - Fork 6
/
pip_cite.ado
197 lines (148 loc) · 6.83 KB
/
pip_cite.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
/*==================================================
project: Citation protocol for PIP wrapper and PIP database
Author: R.Andres Castaneda
E-email: [email protected]
url:
Dependencies: The World Bank
----------------------------------------------------
Creation Date: 13 Jun 2022 - 16:36:52
Modification Date:
Do-file version: 01
References:
Output:
==================================================*/
/*==================================================
0: Program set up
==================================================*/
program define pip_cite, rclass
syntax [anything(name=subcommand)], [ ///
version(string) ///
data_bibtext ///
ado_bibtext ///
reg_cite ///
]
version 16.1
/*==================================================
1: SET UP
==================================================*/
*------------------ Initial Parameters ------------------
qui {
if ("${pip_ado_version}" == "") {
findfile pip.ado
scalar pipado = fileread("`r(fn)'")
mata: pip_ado()
if regexm("`pipver'", "version +([0-9\.]+) +<([a-zA-Z0-9]+)>") {
global pip_ado_version = regexs(1)
global pip_ado_date = regexs(2)
}
} // if global is not found
global pip_adoyear = substr("${pip_ado_date}", 1, 4)
/*==================================================
2: Regular citation
==================================================*/
*##s
if ("`version'" == "") {
qui cap pip_versions
local version = "`r(version)'"
}
//------------ display data bibtext
local data_date = substr("`version'", 1, 8)
local data_year = substr("`version'", 1, 4)
local data_date = date("`data_date'", "YMD")
local data_date: disp %tdCCYY-NN-DD `data_date'
local data_date = trim("`data_date'")
local _version: subinstr local version "_" "\_", all
}
if ("`reg_cite'" != "") {
local cite_ado = `"Castañeda, R.Andrés. (${pip_adoyear}) "pip: Stata Module to Access World Bank’s Global Poverty and Inequality Data" (version ${pip_ado_version}). Stata. Washington, DC: World Bank Group. https://worldbank.github.io/pip/"'
noi disp _n "{hline 90}" ///
as res in smcl "{p 2 8 2}Please cite this Stata tool as:{p_end}" ///
as text `"{p 6 10 4 90}`cite_ado'{p_end}"' ///
"{p 75 0 4}{stata pip_cite, ado_bibtext:bibtext}{p_end}"
local cite_data = `"World Bank. (`data_year'). Poverty and Inequality Platform (version `version') [Data set]. World Bank Group. https://pip.worldbank.org/"'
noi disp as res in smcl _n "{p 2 8 2}Please cite the PIP data as:{p_end}" ///
as text `"{p 6 10 4 100}`cite_data'{p_end}"' ///
"{p 75 0 4}{stata pip_cite, data_bibtext version(`version'):bibtext}{p_end}"
return local cite_ado = `"`cite_ado'"'
return local cite_data = `"`cite_data'"'
exit
}
/*==================================================
3: BibText
==================================================*/
local date = date("`c(current_date)'", "DMY") // %tdDDmonCCYY
local time = clock("`c(current_time)'", "hms") // %tcHH:MM:SS
local date_time = `date'*24*60*60*1000 + `time' // %tcDDmonCCYY_HH:MM:SS
local datetimeHRF: disp %tcDDmonCCYY_HH:MM:SS `date_time'
local dateHRF: disp %tdCCYY-NN-DD `date'
local datetimeMaster: disp %tcCCYYNNDDHHMMSS `date_time'
local datetimeHRF = trim("`datetimeHRF'")
local dateHRF = trim("`dateHRF'")
//------------display ado bibtext
if ("${pip_cite_ado}" == "") {
local ado_date: disp %tdCCYY-NN-DD `ado_date'
local ado_date = date("${pip_ado_date}", "YMD")
local ado_date = trim("`ado_date'")
local crlf "`=char(10)'`=char(13)'"
global pip_cite_ado = ///
"{p 4 8 2}@software{castaneda${pip_adoyear},{p_end}" + ///
"{p 8 12 2}title = {\{pip\}: {{Stata}} Module to Access {{World Bank}}’s {{Global Poverty}} and {{Inequality}} Data},{p_end}" + ///
"{p 8 12 2}shorttitle = {PIP},{p_end}" + ///
"{p 8 12 2}author = {Castañeda, R.Andrés},{p_end}" + ///
"{p 8 12 2}date = {`ado_date'},{p_end}" + ///
"{p 8 12 2}location = {{Washington, DC}},{p_end}" + ///
"{p 8 12 2}url = {https://worldbank.github.io/pip/},{p_end}" + ///
"{p 8 12 2}urldate = {`dateHRF'},{p_end}" + ///
"{p 8 12 2}abstract = {Stata module to access World Bank’s Global Poverty and Inequality data},{p_end}" + ///
"{p 8 12 2}editora = {Degefu, Tefera Bekele},{p_end}" + ///
"{p 8 12 2}editoratype = {collaborator},{p_end}" + ///
"{p 8 12 2}organization = {{World Bank Group}},{p_end}" + ///
"{p 8 12 2}version = {${pip_ado_version}},{p_end}" + ///
"{p 8 12 2}keywords = {api-wrapper}{p_end}" + ///
"{p 4 8 2}}{p_end}"
}
if ("`ado_bibtext'" != "") {
disp _n in smcl `"${pip_cite_ado}"'
exit
}
local pip_cite_data = ///
"{p 4 8 2}@dataset{worldbank`data_year',{p_end}" + ///
"{p 8 12 2}title = {Poverty and {{Inequality Platform}}},{p_end}" + ///
"{p 8 12 2}shorttitle = {{PIP} Database},{p_end}" + ///
"{p 8 12 2}author = {{World Bank}},{p_end}" + ///
"{p 8 12 2}date = {`data_year'},{p_end}" + ///
"{p 8 12 2}publisher = {{World Bank Group}},{p_end}" + ///
"{p 8 12 2}url = {https://pip.worldbank.org/},{p_end}" + ///
"{p 8 12 2}urldate = {`dateHRF'},{p_end}" + ///
"{p 8 12 2}langid = {english},{p_end}" + ///
"{p 8 12 2}version = {`_version'}{p_end}" + ///
"{p 4 8 2}}{p_end}"
if ("`data_bibtext'" != "") {
disp _n in smcl `"`pip_cite_data'"'
exit
}
*##e
end
// ------------------------------------------------------------------------
// MATA functions
// ------------------------------------------------------------------------
* findfile stata.trk
* local fn = "`r(fn)'"
cap mata: mata drop pip_*()
mata:
// function to look for source of code
void pip_ado() {
lines = st_strscalar("pipado")
lines = ustrsplit(lines, "`=char(10)'")'
pipver = select(lines, regexm(lines, `"^\*!"'))[1]
st_local("pipver", pipver)
}
end
exit
/* End of do-file */
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
Notes:
1.
2.
3.
Version Control: