Skip to content

Commit 880cc03

Browse files
authored
Merge pull request #267 from worldbank/v6.4
Merge v6.4 to Master
2 parents 94a5ad3 + 11890a9 commit 880cc03

29 files changed

+355
-74
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,6 @@ _config.yml
6161

6262
#the folder test/ is used for peoples individual testing, this is different from test_scripts/
6363
test/
64+
65+
#Outputs in the run/outputs folder
66+
run/output

admin/checklist-submitting-SSC.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
- [ ] 3.1 **Test in different operative systems** - This step is not necessary every time, but testing the commands in Stata on each of the PC, Mac and Linux operative systems should be done from time to time. A particularly good time to do this is after writing or editing code that depends on file paths, the console, special settings etc. If small updates are needed, then do them in the _version_ branch, otherwise do them in branches of the `develop` branch, merge those to `develop` and then re-merge `develop` to the version branch and test again.
99
- [ ] 3.2 **Update version and date** - In the _version_ branch, update the version number and date in all ado-files and all dates in all help files. See section below for details.
1010
- [ ] 3.3 **Update version locals in ietoolkit** - In the _ietoolkit.ado_ file in the _version_ branch, update the _version_ and _versionDate_ locals at the top of the file.
11-
- [ ] 3.4 **Update version in .pkg and .toc** - This has nothing to do with SSC but should be kept up to date to. This is for when people install directly through GitHub using `net install`
12-
- [ ] 3.5 **Create a .zip file** - Create a .zip file with all ado-files and help files in the folder you just created in the archive folder. Then remove all files but the .zip file from the archive folder.
13-
- [ ] 4. **Email Prof. Baum** - Email the .zip file created in step 3.4 to **[email protected]**.
11+
- [ ] 3.4 **Update version in .pkg and .toc** - This has nothing to do with SSC but should be kept up to date to. This is for when people install directly through GitHub using `net install`. If any new command has been added, remember to add the files for that command to the `.pkg` file.
12+
- [ ] 3.5 **Create a .zip file** - Create a .zip file with all ado-files and help files only. These files are not allowed to be in a sub-folder in this .zip file. No other files should be in this folder. Make a copy of this file in the archive folder of this package.
13+
- [ ] 4. **Email Prof. Baum** - Email the .zip file created in step 3.5 to **[email protected]**.
1414
- [ ] 4.1 - If any commands are added or deleted, make note of that in the email.
15-
- [ ] 4.2 - If any of the meta info (title, description, keywords, version or authour/contact) has changed then include those updates in your email.
15+
- [ ] 4.2 - If any of the meta info (title, description, keywords, version or author/contact) has changed then include those updates in your email.
1616
- [ ] 5. **Draft release note** - Go to the [release notes](https://github.com/worldbank/ietoolkit/releases) and draft a new release note for the new version. Follow the format from previous releases with links to [issues](https://github.com/worldbank/ietoolkit/issues) solved.
1717
- [ ] 6. **Wait for publication confirmation** - Do not proceed pass this step until Prof. Baum has confirmed that the new version is uploaded to the servers.
1818
- [ ] 7. **Merge version branch to *master*** - If step 2 and 3 was done correctly, then there should not be any merge conflicts in this step. Once merged, delete the `version` branch.

run/ie_recurse_rmdir.do

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
* This file can delete all your folders on your computer if used incorrectly.
2+
3+
cap program drop ie_recurse_rmdir
4+
program define ie_recurse_rmdir
5+
6+
qui {
7+
syntax , folder(string) [DRYrun okifnotexist]
8+
9+
/*
10+
folder - full path to folder which should be deleted with all its content
11+
dryrun - just list and do not delete all files that would have been deleted without this option
12+
okifnotexist - it is ok that the top folder does not exist, do not throw erroe
13+
14+
*/
15+
16+
*Test that folder exist
17+
mata : st_numscalar("r(dirExist)", direxists("`folder'"))
18+
19+
if (`r(dirExist)' == 0) {
20+
if missing("`okifnotexist'") {
21+
noi di as error `"{phang}The folder used in [folder(`folder')] does not exist.{p_end}"'
22+
error 693
23+
exit
24+
}
25+
else {
26+
*Folder is missin and that is ok, just output a confirmation that it does not exists
27+
noi di as result `"{phang}The folder used in [folder(`folder')] is already deleted.{p_end}"'
28+
}
29+
}
30+
else {
31+
32+
if (length("`folder'")<=10) {
33+
noi di as error `"{phang}The folder used in [folder(`folder')] does not exist or you have not entered the full path.{p_end}"'
34+
error 693
35+
exit
36+
}
37+
38+
* File paths can have both forward and/or back slash. We'll standardize them so they're easier to handle
39+
local folderStd = subinstr(`"`folder'"',"\","/",.)
40+
41+
*List files, directories and other files
42+
local flist : dir `"`folderStd'"' files "*" , respectcase
43+
local dlist : dir `"`folderStd'"' dirs "*" , respectcase
44+
local olist : dir `"`folderStd'"' other "*" , respectcase
45+
46+
*Use the command on each subfolder to this folder (if any)
47+
foreach dir of local dlist {
48+
*Recursive call on each subfolder
49+
noi ie_recurse_rmdir , folder(`"`folderStd'/`dir'"') `automatic' `dryrun'
50+
}
51+
52+
*REmove all files
53+
local files `"`flist' `olist'"'
54+
foreach file of local files {
55+
*If dryrun then list otherwise delete
56+
if !missing("`dryrun'") noi di as result "{pstd}DRY RUN! Without option {bf:dryrun} file [`folderStd'/`file'] would have been deleted.{p_end}"
57+
else rm `"`folderStd'/`file'"'
58+
}
59+
60+
* Remove this folder as it is now empty
61+
if missing("`dryrun'") {
62+
rmdir `"`folderStd'"'
63+
noi di as result "{pstd}Folder [`folderStd'] and all its content were deleted.{p_end}"
64+
}
65+
}
66+
}
67+
end

run/ieddtab.do

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
2+
/*******************************************************************************
3+
Set up
4+
*******************************************************************************/
5+
6+
* Set versson and seed
7+
ieboilstart , version(13.1)
8+
`r(version)'
9+
set seed 313833
10+
11+
12+
* Add the path to your local clone of the [ietoolkit] repo
13+
14+
global ietoolkit "C:\Users\wb462869\Documents\GitHub\ietoolkit"
15+
qui do "${ietoolkit}/src/ado_files/ieddtab.ado"
16+
17+
18+
* Load data blood pressure patient data
19+
sysuse bplong, clear
20+
21+
*Rename and recode time var
22+
rename when time
23+
recode time (1=0) (2=1)
24+
25+
* Sort patient and time and randomize number on baseline value
26+
bys patient : gen rand = runiform() if time == 0
27+
28+
*Sort rand and assign half of baseline to tmt == 1.
29+
*Baseline is half of all obs, so half bseline = .25
30+
sort rand
31+
gen tmt = (_n / _N > .25) if !missing(rand)
32+
33+
*Sort on patient and time and copy baselin value to endline obs
34+
sort patient time
35+
by patient : replace tmt = tmt[_n-1] if time == 1
36+
37+
*Label vars. USe suffix -test to see what is dynamc and what is hard coded
38+
label define treatment 0 "Control-test" 1 "Treatment-test"
39+
label define time 0 "Baseline-test" 1 "Endline-test"
40+
label value time time
41+
label value tmt treatment
42+
43+
44+
*Tidy up required vars
45+
local orderkeep patient tmt time bp
46+
keep `orderkeep'
47+
order `orderkeep'
48+
49+
50+
**************************************
51+
52+
*Utility function to test result matrix
53+
program define test_matrix
54+
syntax , rmatrix(string) row(string) col(string) expected_val(string)
55+
local value = `rmatrix'["`row'","`col'"]
56+
di "{pstd}Row: `row', Col: `col', Expected value: `expected_val', Actual value `value'{p_end}"
57+
assert `value' == `expected_val'
58+
end
59+
60+
61+
62+
**************************************
63+
64+
*regular run, test all values
65+
ieddtab bp, time(time) treat(tmt)
66+
67+
mat result1 = r(ieddtabResults)
68+
mat list result1
69+
70+
*Test second difference
71+
test_matrix , rmatrix(result1) row("bp") col("2D") expected_val(-1.649999999999993)
72+
test_matrix , rmatrix(result1) row("bp") col("2D_err") expected_val(3.332609384661584)
73+
test_matrix , rmatrix(result1) row("bp") col("2D_stars") expected_val(0)
74+
test_matrix , rmatrix(result1) row("bp") col("2D_N") expected_val(240)
75+
76+
*Test control first difference
77+
test_matrix , rmatrix(result1) row("bp") col("1DC") expected_val(-4.266666666666667)
78+
test_matrix , rmatrix(result1) row("bp") col("1DC_err") expected_val(2.39864211429447)
79+
test_matrix , rmatrix(result1) row("bp") col("1DC_stars") expected_val(1)
80+
test_matrix , rmatrix(result1) row("bp") col("1DC_N") expected_val(120)
81+
82+
*Test treatment first difference
83+
test_matrix , rmatrix(result1) row("bp") col("1DT") expected_val(-5.916666666666667)
84+
test_matrix , rmatrix(result1) row("bp") col("1DT_err") expected_val(2.313612179745651)
85+
test_matrix , rmatrix(result1) row("bp") col("1DT_stars") expected_val(2)
86+
test_matrix , rmatrix(result1) row("bp") col("1DT_N") expected_val(120)
87+
88+
*Test control baseline summary stats
89+
test_matrix , rmatrix(result1) row("bp") col("C0_mean") expected_val(156.0666666666667)
90+
test_matrix , rmatrix(result1) row("bp") col("C0_err") expected_val(1.594458388227513)
91+
test_matrix , rmatrix(result1) row("bp") col("C0_N") expected_val(60)
92+
93+
*Test treatment baseline summary stats
94+
test_matrix , rmatrix(result1) row("bp") col("T0_mean") expected_val(156.8333333333333)
95+
test_matrix , rmatrix(result1) row("bp") col("T0_err") expected_val(1.346719526847542)
96+
test_matrix , rmatrix(result1) row("bp") col("T0_N") expected_val(60)
97+
98+
*Test control endline summary stats
99+
test_matrix , rmatrix(result1) row("bp") col("C1_mean") expected_val(151.8)
100+
test_matrix , rmatrix(result1) row("bp") col("C1_err") expected_val(1.791978359433497)
101+
test_matrix , rmatrix(result1) row("bp") col("C1_N") expected_val(60)
102+
103+
*Test treatment endline summary stats
104+
test_matrix , rmatrix(result1) row("bp") col("T1_mean") expected_val(150.9166666666667)
105+
test_matrix , rmatrix(result1) row("bp") col("T1_err") expected_val(1.881262298105969)
106+
test_matrix , rmatrix(result1) row("bp") col("T1_N") expected_val(60)
107+
108+

run/iegitaddmd.do

+46-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11

22
* Set this local to a folder where folders can be creaetd for this experiment
3-
global test_folder ""
3+
global ietoolkit_clone "C:\Users\wb462869\Documents\GitHub\ietoolkit"
4+
global test_folder "${ietoolkit_clone}\run\output\iegitaddmd"
5+
6+
qui do "${ietoolkit_clone}/run/ie_recurse_rmdir.do"
7+
8+
* Make sure this folder is created
9+
cap mkdir "${ietoolkit_clone}\run\output\iegitaddmd"
410

5-
* Create a folder clone and a folder dropbox (see use case 2 in help file for why both these folders are needed)
6-
mkdir "${test_folder}/clone"
7-
mkdir "${test_folder}/dropbox"
811

12+
* Create a folder clone and a folder dropbox (see use case 2 in help file for why both these folders are needed)
13+
local highlevel_folders clone dropbox gitfilter1 gitfilter2
14+
foreach folder of local highlevel_folders {
15+
ie_recurse_rmdir, folder("${test_folder}/`folder'") okifnotexist
16+
mkdir "${test_folder}/`folder'"
17+
}
18+
919
* USe iefolder to create identical project folders
1020
iefolder new project , projectfolder("${test_folder}/clone")
1121
iefolder new project , projectfolder("${test_folder}/dropbox")
@@ -23,18 +33,46 @@
2333
rmdir "${test_folder}/clone/DataWork/Baseline/DataSets"
2434
rmdir "${test_folder}/clone/DataWork/Baseline/Questionnaire/Questionnaire Documentation"
2535

36+
* Create the git folder
37+
local gitfolders gitfilter1 gitfilter2
38+
foreach gitfolder of local gitfolders {
39+
mkdir "${test_folder}/`gitfolder'/.git"
40+
mkdir "${test_folder}/`gitfolder'/includeme"
41+
mkdir "${test_folder}/`gitfolder'/skipmein2"
42+
mkdir "${test_folder}/`gitfolder'/skipalsomein2"
43+
mkdir "${test_folder}/`gitfolder'/sub"
44+
mkdir "${test_folder}/`gitfolder'/sub/.git"
45+
mkdir "${test_folder}/`gitfolder'/sub/includealsome"
46+
47+
mkdir "${test_folder}/`gitfolder'/ado"
48+
mkdir "${test_folder}/`gitfolder'/asdfasd"
49+
mkdir "${test_folder}/`gitfolder'/asdfasd/ado"
50+
}
51+
52+
2653
*Set global to ietoolkit clone
27-
global ietoolkit_clone ""
2854
qui do "${ietoolkit_clone}/src/ado_files/iegitaddmd.ado"
2955

3056
*Use case 1 - see helpfile for description of use cases
3157
iegitaddmd , folder("${test_folder}/clone/DataWork") auto dryrun
3258
iegitaddmd , folder("${test_folder}/clone/DataWork") auto
3359

3460
*Use case 2 - see helpfile for description of use cases
35-
iegitaddmd , folder("${test_folder}/clone/DataWork") comparefolder("${test_folder}/dropbox/DataWork") auto dryrun
36-
iegitaddmd , folder("${test_folder}/clone/DataWork") comparefolder("${test_folder}/dropbox/DataWork") auto
61+
iegitaddmd , folder("${test_folder}/clone\DataWork") comparefolder("${test_folder}/dropbox\DataWork") auto dryrun
62+
iegitaddmd , folder("${test_folder}/clone\DataWork") comparefolder("${test_folder}/dropbox\DataWork") auto
3763

3864
*Test prompt
3965
mkdir "${test_folder}/clone/DataWork/Baseline/DataSets/Final/Publishable"
40-
iegitaddmd , folder("${test_folder}/clone/DataWork")
66+
*iegitaddmd , folder("${test_folder}/clone/DataWork")
67+
68+
*Test skip git folders
69+
iegitaddmd , folder("${test_folder}/gitfilter1") auto
70+
71+
*Test skip custom
72+
iegitaddmd , folder("${test_folder}/gitfilter2") auto dry skipfolders(skipmein2 skipalsomein2 folderthatnotexist ado)
73+
iegitaddmd , folder("${test_folder}/gitfilter2") auto skipfolders(skipmein2 skipalsomein2 folderthatnotexist ado)
74+
75+
* Test that folders are not used
76+
cap iegitaddmd , folder("${test_folder}/gitfilter2") auto skipfolders(skipmein2 skipalsomein2 folderthatnotexist asdfasd/ado)
77+
assert _rc == 198
78+

src/ado_files/iebaltab.ado

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*! version 6.3 5NOV2019 DIME Analytics [email protected]
1+
*! version 6.4 11JAN2022 DIME Analytics [email protected]
22

33
capture program drop iebaltab
44
program iebaltab

src/ado_files/ieboilsave.ado

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*! version 6.3 5NOV2019 DIME Analytics [email protected]
1+
*! version 6.4 11JAN2022 DIME Analytics [email protected]
22

33
capture program drop ieboilsave
44
program ieboilsave , rclass

src/ado_files/ieboilstart.ado

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*! version 6.3 5NOV2019 DIME Analytics [email protected]
1+
*! version 6.4 11JAN2022 DIME Analytics [email protected]
22

33
capture program drop ieboilstart
44
program ieboilstart , rclass
@@ -16,7 +16,8 @@
1616
1717
*********************************/
1818

19-
local stata_versions "11 11.0 11.1 11.2 12 12.0 12.1 13 13.0 13.1 14 14.0 14.1 14.2 15 15.0 15.1"
19+
* Based on versions listed here: https://www.stata.com/support/faqs/resources/history-of-stata/
20+
local stata_versions "11 11.0 11.1 11.2 12 12.0 12.1 13 13.0 13.1 14 14.0 14.1 14.2 15 15.0 15.1 16.0 16.1 17.0"
2021

2122
if `:list versionnumber in stata_versions' == 0 {
2223

src/ado_files/ieddtab.ado

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*! version 6.3 5NOV2019 DIME Analytics [email protected]
1+
*! version 6.4 11JAN2022 DIME Analytics [email protected]
22

33
cap program drop ieddtab
44
program define ieddtab, rclass
@@ -676,7 +676,7 @@ cap program drop templateResultMatrix
676676
local basicMean_C1_cols C1_mean C1_err C1_N C1_clus
677677
local basicMean_T1_cols T1_mean T1_err T1_N T1_clus
678678

679-
local colnames `2ndDiff_cols' `1stDiff_C_cols' `1stDiff_T_cols' `basicMean_C0_cols' `basicMean_T0_cols' `basicMean_C1_cols' `basicMean_T0_cols'
679+
local colnames `2ndDiff_cols' `1stDiff_C_cols' `1stDiff_T_cols' `basicMean_C0_cols' `basicMean_T0_cols' `basicMean_C1_cols' `basicMean_T1_cols'
680680

681681
*Define default row here. The results for each var will be one row that starts with all missing vlaues
682682
mat startRow = (.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.)

src/ado_files/iedropone.ado

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*! version 6.3 5NOV2019 DIME Analytics [email protected]
1+
*! version 6.4 11JAN2022 DIME Analytics [email protected]
22

33
capture program drop iedropone
44
program define iedropone ,

src/ado_files/iefolder.ado

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*! version 6.3 5NOV2019 DIME Analytics [email protected]
1+
*! version 6.4 11JAN2022 DIME Analytics [email protected]
22

33
cap program drop iefolder
44
program define iefolder
@@ -899,7 +899,7 @@ cap program drop mdofle_p0
899899
file write `subHandle' ///
900900
_col(4)"*Install all packages that this project requires:" _n ///
901901
_col(4)"*(Note that this never updates outdated versions of already installed commands, to update commands use adoupdate)" _n ///
902-
_col(4)"local user_commands ietoolkit" _col(40) "//Fill this list will all user-written commands this project requires" _n ///
902+
_col(4)"local user_commands ietoolkit iefieldkit" _col(40) "//Fill this list will all user-written commands this project requires" _n ///
903903
_col(4)"foreach command of local user_commands {" _n ///
904904
_col(8) "cap which " _char(96) "command'" _n ///
905905
_col(8) "if _rc == 111 {" _n ///

0 commit comments

Comments
 (0)