More progress

More progress

Added some more information

{smcl}
{* 26 Dec 2016}{...}
{hline}
help for {hi:iegraph}
{hline}

{title:Title}

{phang2}{cmdab:iegraph} {hline 2} Generates graphs based on regressions done during typical impact evaluation.

{title:Syntax}

{phang2}
{cmdab:iegraph} {varlist}
, [{cmd:noconfbars} {cmdab:TI:tle(}{it:string}{cmd:)}
{cmdab:save(}{it:string}{cmd:)} {cmdab:confbarsnone(}{it:varlist}{cmd:)}
]

{marker opts}{...}
{synoptset 22}{...}
{synopthdr:options}
{synoptline}
{synopt :{cmd:noconfbars}}Removes the confidence interval bars from graphs for all treatments.{p_end}
{synopt :{cmdab:TI:tle(}{it:string}{cmd:)}}Manually sets the title of the graph.{p_end}
{synopt :{cmdab:save(}{it:string}{cmd:)}}Sets the filename and the directory to which the graph will be set.{p_end}
{synopt :{cmdab:confbarsnone(}{it:varlist}{cmd:)}}Removes confidence interval bars from only the {it:varlist} listed.{p_end}
{synoptline}

{marker desc}
{title:Description}

{pstd}{cmdab:iegraph}This command creates bar graphs on the average treatment effects
	for multiple treatments in a impact evaluation project. The command creates bar
	graphs for the mean of the control group and for the various treatment groups. {p_end}

{marker optslong}
{title:Options}

{phang}{cmd:noconfbars}Removes the confidence interval bars from graphs for all
	treatments.{p_end}

{phang}{cmdab:TI:tle(}{it:string}{cmd:)}Manually sets the title of the graph.{p_end}

{phang}{cmdab:save(}{it:string}{cmd:)}Sets the filename and the directory to which
	the graph will be set.{p_end}

{phang}{cmdab:confbarsnone(}{it:varlist}{cmd:)}Removes confidence interval bars
	from only the {it:varlist} listed. The remaining variables in the graphs which
	have not been specified in {cmdab:confbarsnone} will still have the confidence
	interval bars. {p_end}

{title:Examples}

{pstd} {hi:Example 1.}

{pmore}{inp:iegraph treatmentVar1 treatmentvar2 , title({it:string})}

{pmore}In the example above, the observations with value 1 in {it:tmt} will be matched
	towards the nearest, in terms of {it:p_hat}, observations with value 0 in {it:tmt}.

{pstd} {hi:Example 2.}

{pmore}{inp:iematch if {it:baseline} == 1  , grpdummy({it:tmt}) matchvar({it:p_hat}) maxdiff(.001)}

{pmore}In the example above, the observations with value 1 in {it:tmt} will be matched
	towards the nearest, in terms of {it:p_hat}, observations with value 0 in {it:tmt} as
	long as the difference in {it:p_hat} is less than .001. Only observations that has the
	value 1 in variable {it:baseline} will be included in the match.

{title:Acknowledgements}

{phang}I would like to acknowledge the help in testing and proofreading I received in relation to this command and help file from (in alphabetic order):{p_end}
{pmore}{break}

{title:Author}

{phang}Kristoffer Bjarkefur & Mrijan Rimal, The World Bank, DECIE

{phang}Please send bug-reports, suggestions and requests for clarifications
		 writing "ietools iegraph" in the subject line to:{break}
		 kbjarkefur@worldbank.org

{phang}You can also see the code, make comments to the code, see the version
		 history of the code, and submit additions or edits to the code through
		 the github repository of ietoolkit:{break}
		 {browse "https://github.com/worldbank/ietoolkit"}

{smcl}
{* 26 Dec 2016}{...}
{hline}
help for {hi:iegraph}
{hline}

{title:Title}

{phang2}{cmdab:iegraph} {hline 2} Generates graphs based on regressions done during typical impact evaluation.

{title:Syntax}

{phang2}
{cmdab:iegraph} {varlist}
, [{cmd:noconfbars} {cmdab:TI:tle(}{it:string}{cmd:)}
{cmdab:save(}{it:string}{cmd:)} {cmdab:confbarsnone(}{it:varlist}{cmd:)}
]

{marker opts}{...}
{synoptset 22}{...}
{synopthdr:options}
{synoptline}
{synopt :{cmd:noconfbars}}Removes the confidence interval bars from graphs for all treatments.{p_end}
{synopt :{cmdab:TI:tle(}{it:string}{cmd:)}}Manually sets the title of the graph.{p_end}
{synopt :{cmdab:save(}{it:string}{cmd:)}}Sets the filename and the directory to which the graph will be set.{p_end}
{synopt :{cmdab:confbarsnone(}{it:varlist}{cmd:)}}Removes confidence interval bars from only the {it:varlist} listed.{p_end}
{synoptline}

{marker desc}
{title:Description}

{pstd}{cmdab:iematch} matches base observations towards target observations in terms
	of nearest value in {cmd:matchvar()}. Base observations are observations with
	value 1 in {cmd:grpdummy()} and target observations are observations with value
	0. For example, in a typical p-score match, base observations are treatment and
	target is control, however, there are many other examples of matching where it could
	be different.

{pstd}{cmdab:iematch} bases its matching algorithm on the Stable Marriage algorithm.
	This algorithm was chosen because it always provides a solution and allows stable
	matching even if multiple observations have identical match
	values (see {cmd:seed()} option for more details). One disadvantage of this
	algorithm is that it takes into account local efficiency only, and not global efficiency. This
	means that it is possible that other matching algorithms might generate a more
	efficient match in terms of the sum of the difference of all matched pairs/groups.

{pstd}{hi:{ul:One-to-one matching algorithm}}{break}
	The algorithm used in a one-to-one match starts by evaluating which
	target observation each base observation is closest to and vice versa for each
	target observations. If a base and target observation pair mutually prefer
	each other, then these two observations are matched. The algorithm then repeats
	the initial two evaluation steps, and excludes observations after they are matched,
	until all base observations are either matched or excluded due to the option {cmdab:maxdiff()}.
	Matched observations ends up in pairs of exactly one base observation and one
	target observation.

{pstd}In a one-to-one match, there has to be at least as many target observations
	as there are base observations. A one-to-one match returns three variables. One
	variable indicates the result of the matching for each observation, such as,
	matched, not matched, no match within the max difference, etc. The other two variables
	hold information on the matched pair. One variable is the ID of the target observation
	in the matched pair, and the other variable is the difference in {cmd:matchvar()}
	between the two observations in the match pair. See the below in this section
	for more details on the variables generated.

{pstd}{hi:{ul:Many-to-one matching algorithm}}{break}
	The algorithm used for many-to-one matching is the same as in a one-to-one match. But instead
	of matching only when there is a mutual preference, all base observations are
	matched towards their preferred target observation in the first step, as long
	as the match is within the max-value if {cmdab:maxdff()} is used. Matched observations
	end up in groups in which there is exactly one target observation but where there are
	either one or several base observations.

{pstd}In a many-to-one match, there is no restriction in terms of the number of
	base observations in relation to target observations. The many-to-one matching
	yields four variables. Three of the variables are the same as in one-to-one
	matching, and only the variable listing the difference  The fourth variable indicates how many base observations that were matched
	towards each target observation. See the below in this section for more details on
	the variables generated.

{pstd}{hi:{ul:Variables generated}}{break}
	This section explains the variables that are generated by this command. All variables
	will be referred to by their default names, but those names can be manually set to somthing
	else (see the options for this command).

{pstd}{hi:_matchResult}{break}
	This variable indicates the result of the match for all observations. Observations
	that ended up in a match pair/group has the value 1. Target observations not matched have the
	value 0. Base observations without a valid match due to {cmdab:maxdff()} are
	assigned the value .d. Observations excluded from the match using {inp:if}/{inp:in} are
	assigned the value .i. Observations excluded from the match due to missing value in {cmd:grpdummy()} are
	assigned the value .g. Observations excluded from the match due to missing value in {cmd:matchvar()} are
	assigned the value .m. All values have descreptive value labels.

{pstd}{hi:_matchID}{break}
	This variable indicates the ID of the target observations in each match pair/group. For matched
	target observations, the value in _matchID will be equal to the value in the ID
	variable. Since the values in the ID varaible are unique and there is exactly one target
	observation in each matched pair/group, this variable functions as a unique pair/group ID.
	In addition to indicating which observations are included in the same pair/group, this
	varaible can be used to include a pair/group fixed effect in a regression.

{pstd}{hi:_matchDiff}{break}
	This variable indicates the difference in {cmd:matchvar()} between matched base observations
	and target observations. In a one-to-one match this value is the identical for
	both the base observation and the target observation in each matched pair.
	In a many-to-one match, this value is only indicated for base observations. It is
	missing for target observations as there are potentially multiple matches, and
	subsequently multiple differences.

{pstd}{hi:_matchCount}{break}
	In a many-to-one match, this variable indicates how many base observations were
	matched towards each matched target observation. This variable can be used as regression
	weights when controlling for the fact that some observations are matched towards multiple
	observations.

{marker optslong}
{title:Options}

{phang}{cmd:noconfbars}Removes the confidence interval bars from graphs for all
	treatments.{p_end}

{phang}{cmdab:TI:tle(}{it:string}{cmd:)}Manually sets the title of the graph.{p_end}

{phang}{cmdab:save(}{it:string}{cmd:)}Sets the filename and the directory to which
	the graph will be set.{p_end}

{phang}{cmdab:confbarsnone(}{it:varlist}{cmd:)}Removes confidence interval bars
	from only the {it:varlist} listed. The remaining variables in the graphs which
	have not been specified in {cmdab:confbarsnone} will still have the confidence
	interval bars. {p_end}

{title:Examples}

{pstd} {hi:Example 1.}

{pmore}{inp:iegraph treatmentVar1 treatmentvar2 , title({it:string})}

{pmore}In the example above, the observations with value 1 in {it:tmt} will be matched
	towards the nearest, in terms of {it:p_hat}, observations with value 0 in {it:tmt}.

{pstd} {hi:Example 2.}

{pmore}{inp:iematch if {it:baseline} == 1  , grpdummy({it:tmt}) matchvar({it:p_hat}) maxdiff(.001)}

{pmore}In the example above, the observations with value 1 in {it:tmt} will be matched
	towards the nearest, in terms of {it:p_hat}, observations with value 0 in {it:tmt} as
	long as the difference in {it:p_hat} is less than .001. Only observations that has the
	value 1 in variable {it:baseline} will be included in the match.

{title:Acknowledgements}

{phang}I would like to acknowledge the help in testing and proofreading I received in relation to this command and help file from (in alphabetic order):{p_end}
{pmore}{break}

{title:Author}

{phang}Kristoffer Bjarkefur & Mrijan Rimal, The World Bank, DECIE

{phang}Please send bug-reports, suggestions and requests for clarifications
		 writing "ietools iegraph" in the subject line to:{break}
		 kbjarkefur@worldbank.org

{phang}You can also see the code, make comments to the code, see the version
		 history of the code, and submit additions or edits to the code through
		 the github repository of ietoolkit:{break}
		 {browse "https://github.com/worldbank/ietoolkit"}


minor changes

minor changes

clear all
set more off
set matsize 11000
global path "/mnt/nfs6/wikipedia.proj/jmp/jmpscripts/stata/"
global rawosm "/mnt/nfs6/wikipedia.proj/jmp/rawdata/osm/"
global osmchange "/mnt/nfs6/wikipedia.proj/jmp/rawdata/osmchange/"
global rawmaps "/mnt/nfs6/wikipedia.proj/jmp/rawdata/maps/"
global rawtrips "/mnt/nfs6/wikipedia.proj/jmp/rawdata/trips/"
global stash "/mnt/nfs6/wikipedia.proj/jmp/rawdata/stash/"
global myestimates "/mnt/nfs6/wikipedia.proj/jmp/jmpscripts/stata/estimates/"
global tables "/mnt/nfs6/wikipedia.proj/jmp/jmpscripts/stata/tables/"
global rawhist "/mnt/nfs6/wikipedia.proj/jmp/rawdata/osmhistory/"
global clist "/mnt/nfs6/wikipedia.proj/jmp/rawdata/clist/"

adopath + "/mnt/nfs6/wikipedia.proj/jmp/jmpscripts/stata/ado"

cd ${path}

program drop _all

 // STEP 0 -- clean 3 datasets (change, msa, county)
 // TODO: add tileid logic

 // Step 1.2 -- create outcome variables
 // Step 1.3 -- fills in blanks and xtset the data

// for geoid10-fips
use ${stash}mergemaster1, clear
makedv "fips geoid10"
balancepanel geoid10
save ${stash}panelfips_geoid10, replace

 // just geoid
 use ${stash}mergemaster1, clear
 drop if geoid10 == "NA"
 bysort geoid10 fips: gen tmp = _n==1
 gen treattmp = treat
 replace treattmp = . if tmp == 0
 bysort geoid10: egen avgtreat = mean(treattmp)
 replace treat = avgtreat
 drop treattmp tmp avgtreat
 makedv "geoid10"
 balancepanel geoid10
 save ${stash}panelgeoid10, replace

 ** Analysis

// 0. Data

// 0.1 make fips dataset
preparebasic
mergebasic

use ${stash}mergemaster1, clear
makedv fips
balancepanel fips
save ${stash}panelfips, replace

// 0.2 make node dataset
preparenode

use ${stash}mergemaster_node, clear
makedv fips node
balancepanel fips node
save ${stash}panelnode, replace

// Analysis

// 1. Summary stats
use ${stash}panelfips, clear
makesummary

// 2. Treatment vs. control charts
use ${stash}panelfips, clear
makehist cntypop kdensity
makehist region hist

// 3. Baseline effects (xtpoisson, cluster at unit level)

//  3.1 Meanline charts (raw data)
makemeanline numchanges quarter 2011 "Changes"
makemeanline numcontrib quarter 2011 "Contributions"
makemeanline numuser quarter 2011 "Users"
makemeanline numserious90 quarter 2011 "Super Users"
makemeanline numnewusers quarter 2011 "New Users"
makemeanline numnewusers6 quarter 2011 "New Users (Stay for 6+ Months)"
makemeanline numnewusers90 quarter 2011 "New Users (who become super users)"

// 3.2 FIPS Sample -- DD

/// 3.2.1 -- contrib, users, superu
program drop _all

clear
local dv "numcontrib numuser numserious90"
local unit fips
rundd panelfips `unit' "`dv'"
diffindiff xtpoisson "`dv'" `unit' 2014 write tab_3.2.1 "Contributions" "Users" "Super Users"

/// 3.2.2 -- newusers, newusers6, newuserssuper
clear
local dv "numnewusers numnewusers6 numnewusers90"
local unit fips
rundd panelfips `unit' "`dv'"
diffindiff xtpoisson "`dv'" `unit' 2014 write tab_3.2.2 "New Users" "New Users(6+)" "New Super Users"

/// 3.2.3 -- streetcontrib, nonstreet contrib, amenities
// TODO

use ${stash}panelnode, clear
program drop _all

diffindiff xtpoisson fips run tab_test numcontrib numuser

/// 3.2.4 -- completeness
// TODO

// 3.2.5 -- Diff in Diff charts
// TODO : make this more flexible
// TODO : this works only for fips
ddchart

// 3.3 Robustness : Drop empty counties
// TODO
//  e. Repeat (a) by dropping empty counties
//  f. Repeat (a) by dropping west
//  g. Repeat (a) for Tile Sample, MSA sample
//  h. Repeat (a) with matched estimators
//  i. Repeat (a) with spatially clustered se, Region X Time trends

// 4 Heterogenous Effects

// 1. Large vs. small
use ${stash}panelfips, clear
gen large = (cntypop > 100000)

diffindiff2 large LARGE tab_4.1 run numcontrib numuser numserious90 numnewusers6

diffindiff2 large LARGE tab_4.1 write numcontrib numuser numserious90 numnewusers6

// 2. engaged vs. non-engaged county

use ${stash}panelfips, clear

bysort fips post: egen tmp = total(numcontrib > 0)
replace tmp = . if post == 1
bysort fips: egen precontrib = max(tmp)
bysort fips: egen totcontrib = total(numcontrib)
drop tmp

drop if precontrib == 0
gen active = (prec > 1)

diffindiff2 active ACTIVE tab_4.2 run numcontrib numuser numserious90 numnewusers6

diffindiff2 active ACTIVE tab_4.2 write numcontrib numuser numserious90 numnewusers6

// 3. populated vs. not

use ${stash}panelfips, clear

gen iseast = (region==1 | region == 2)

diffindiff2 iseast EAST tab_4.3 run numcontrib numuser numserious90 numnewusers6

diffindiff2 iseast EAST tab_4.3 write numcontrib numuser numserious90 numnewusers6

// 3. urban vs rural
// 4. university vs non university
// 5. rich vs poor

// 5 Person Level Regressions

// [A] outcome vars: County sample -- DD spec

   // a. Contributions
   // b. Street, Non Street
   // b. TIGER vs. Non Tiger
   // d. Home county, Num Counties

// [B] heterogenous

   // a. Junior vs Senior

// 6 Impacts on Craigslist

preparecl

// PENDING

// GEOID Level

// TASKS for tomorrow

// STASH

 // 1.1 Mean Charts

 // 1.2 Produce Diff in diff Latex tables
 // rundd -> batchreg.sh -> runreg.do -> diffindiff.ado
 program drop _all

 // TODO: fix manual process
 // have to do this manually

 // 1.3 Produce Diff in diff Pictures

 ** person level regressions
 // person level
 makeperson
 ddperson maketables
 ddperson makechart

// TODOs for Tuesday Jun 3
// GEOID dataset
// TILEID diff in diff
// What happened to previous people?
// What happened at the street/amenity level?
// Urban vs Rural (framework for third level diff)

// 1.4 Robust: product diff in diff for GEOID

use ${stash}panelfips_geoid10, clear

** Analysis Stage 2
//

// PROGRAMS


Improve CC.do

Improve CC.do

redo-ifchange config.sh
. ./config.sh

exec >$3
cat <<-EOF
	redo-ifchange "\$SRCDIR/\$2.c"
	$CC $CFLAGS -MD -MF /dev/fd/1 -o \$3 -c "\$SRCDIR/\$2.c" \
			| sed 's/^[^:]*://g; s/ \\\\//g' | xargs redo-ifchange
EOF
chmod +x $3

redo-ifchange config.sh
. ./config.sh

exec >$3
cat <<-EOF
	redo-ifchange "\$SRCDIR/\$2.c"
	temp=\$($CC $CFLAGS -MD -MF /dev/fd/1 -o \$3 -c "\$SRCDIR/\$2.c")
	echo \$temp | sed 's/^[^:]*://g' | sed 's/ \\\\//g' | xargs redo-ifchange
EOF
chmod +x $3


ietoolkit help small edits

ietoolkit help small edits

{smcl}
{* 15 Dec 2017}{...}
{hline}
help for {hi:ietoolkit}
{hline}

{title:Title}

{phang}{cmdab:ietoolkit} {hline 2} Returns information on the version of ietoolkit installed

{phang}For a more descriptive discussion on the intended usage and work flow of this
command please see the {browse "https://dimewiki.worldbank.org/wiki/Ietoolkit":DIME Wiki}.

{title:Syntax}

{phang}
{cmdab:ietoolkit}

{pstd}Note that this command takes no arguments at all.{p_end}

{marker desc}
{title:Description}

{pstd}{cmdab:iegraph} This command returns the version of ietoolkit installed. It
	can be used in the beginning of a Master Do-file that is intended to be used
	by multiple users to programmatically test if ietoolkit is not installed for
	the user and therefore need to be installed, or if the version the user has
	installed is too old and needs to be upgraded.

{marker optslong}
{title:Options}

{phang}This command does not take any options.

{marker example}
{title:Examples}

{pstd}The code below is an example code that can be added to the top of any do-file.
	the example code first test if the command is installed, and install it if not. If it is
	installed, it test if the version is less than version 5.0. If it is, it
	replaces the ietoolkit file with the latest version. In your code you can skip
	the second part if you are not sure which version is required. But you should
	always have the first part testing that {inp:r(version)} has a value before using
	it in less than or greater than expressions.

{inp}    cap ietoolkit
{inp}    if "`r(version)'" == "" {
{inp}      *ietoolkit not installed, install it
{inp}      ssc install ietoolkit
{inp}    }
{inp}    else if `r(version)' < 5.0 {
{inp}      ietoolkit version too old, install the latest version
{inp}      ssc install ietoolkit , replace
{inp}    }{text}

{title:Acknowledgements}

{phang}We would like to acknowledge the help in testing and proofreading we received
 in relation to this command and help file from (in alphabetic order):{p_end}
{pmore}Luiza Cardoso De Andrade{break}Seungmin Lee{break}

{title:Authors}

{phang}Kristoffer Bjarkefur, The World Bank, DECIE

{phang}Please send bug-reports, suggestions and requests for clarifications
		 writing "ietoolkit ietoolkit" in the subject line to the email address
		 found {browse "https://github.com/worldbank/ietoolkit":here}

{phang}You can also see the code, make comments to the code, see the version
		 history of the code, and submit additions or edits to the code through
		 the github repository of ietoolkit:{break}
		 {browse "https://github.com/worldbank/ietoolkit"}

{smcl}
{* 15 Dec 2017}{...}
{hline}
help for {hi:iegraph}
{hline}

{title:Title}

{phang}{cmdab:ietoolkit} {hline 2} Returns information on the version of ietoolkit installed

{phang}For a more descriptive discussion on the intended usage and work flow of this
command please see the {browse "https://dimewiki.worldbank.org/wiki/Ietoolkit":DIME Wiki}.

{title:Syntax}

{phang}
{cmdab:ietoolkit}

{pstd}Note that this command takes no arguements at all.{p_end}

{marker desc}
{title:Description}

{pstd}{cmdab:iegraph} This command returns the version of ietoolkit installed. It
	can be used in the beginning of a Master Do-file that is intended to be used
	by mutliple users to programmatically test if ietoolkit is not installed for
	the user and therefore need to be installed, or if the version the user has
	installed is too old and needs to be upgraded.

{marker optslong}
{title:Options}

{phang}This command does not take any options.

{marker example}
{title:Examples}

{pstd}The code below is an example code that can be added to the top of any dofile.
	the example code first test if the command is installed, and install it if not. If it is
	installed, it test if the version is less than version 5.0. If it is, it
	replaces the ietoolkit file with the latest version. In your code you can skip
	the second part if you are not sure which version is required. But you should
	always have the first part testing that {inp:r(version)} has a value before using
	it in less than or greater than expressions.

{inp}    cap ietoolkit
{inp}    if "`r(version)'" == "" {
{inp}      *ietoolkit not installed, install it
{inp}      ssc install ietoolkit
{inp}    }
{inp}    else if `r(version)' < 5.0 {
{inp}      ietoolkit version too old, install the latest version
{inp}      ssc install ietoolkit , replace
{inp}    }{text}

{title:Acknowledgements}

{phang}We would like to acknowledge the help in testing and proofreading we received
 in relation to this command and help file from (in alphabetic order):{p_end}
{pmore}Luiza Cardoso De Andrade{break}Seungmin Lee{break}

{title:Authors}

{phang}Kristoffer Bjarkefur, The World Bank, DECIE

{phang}Please send bug-reports, suggestions and requests for clarifications
		 writing "ietoolkit ietoolkit" in the subject line to the email address
		 found {browse "https://github.com/worldbank/ietoolkit":here}

{phang}You can also see the code, make comments to the code, see the version
		 history of the code, and submit additions or edits to the code through
		 the github repository of ietoolkit:{break}
		 {browse "https://github.com/worldbank/ietoolkit"}


ieboilstart : help file update

ieboilstart : help file update

{smcl}
{* 1 Nov 2016}{...}
{hline}
help for {hi:ieboilstart}
{hline}

{title:Title}

{phang2}{cmdab:ieboilstart} {hline 2} Creates a dofile that harmonizes the settings
accross team members in the same project to the longest extent technically possible.

{phang2}{hi:DISCLAIMER} {hline 1} There are several technical reasons why it is
impossible to guarantee that different types of Stata (version number, Small/IC/SE/MP
or PC/Mac/Linux) work exactly the same in every possible context. However, this command
gathers best practices used across the Stata community to mitigate the risk of behaving
differently. See more details {help ieboilstart##comp:below}.

{title:Syntax}

{pstd}Note that due to technical requirements in Stata, there are two crucial details on
how to use this command correctly.{p_end}

{pstd}The most important detail is to execute the dofile generated by using {cmd:include} and
not {cmd:do} or {cmd:run}. Otherwise version number, which is probably
the most important part of this command, is not set correctly.{p_end}

{pstd}The second detail is that both parts below needs to be executed. The first part only
generates the dofile with all recommended settings, and the second part execute them. The
second part can be done multiple times after the first part is done once.{p_end}

{phang2}{it:First part:}{break}
{cmdab:ieboilstart} using {help filename :filename}.do
, {cmdab:v:ersionnumber(}{it:string}{cmd:)}  [{cmdab:maxvar(}{it:numlist}{cmd:)}
{cmdab:matsize(}{it:numlist}{cmd:)} {cmd:noclear} {cmdab:qui:etdo}
{cmdab:cust:om(}{it:string}{cmd:)} {cmdab:setmem(}{it:string}{cmd:)}]

{phang2}{it:Second part if following immediately after main part (recommended):}{break}
{cmdab:include} "`r(ieboil_dofile)'"

{phang2}{it:Second part anywhere in a dofile:}{break}
{cmdab:include} {help filename :filename}{it:.do}

{pstd}See more details on why two parts are required and why {cmd:include} must
be used instead of {cmd:do} or {cmd:run}.

{marker opts}{...}
{synoptset 20}{...}
{synopthdr:options}
{synoptline}
{synopt :{cmdab:v:ersionnumber(}{it:string}{cmd:)}}sets a stable version of Stata
	that always applies regardless of which [newer] version of Stata the
	dofile is executed in after running this command.{p_end}
{synopt :{cmdab:maxvar(}{it:numlist}{cmd:)}}manually sets the maximum number of
	variables allowed in a data set. The default if omitted is 32,767.{p_end}
{synopt :{cmdab:matsize(}{it:numlist}{cmd:)}}manually sets the maximum number of
	variables allowed in an estimation command, for example {help regress:regress}.
	The default if omitted is 400.{p_end}
{synopt :{cmdab:noclear}}prevents the command from clearing data in memory. The
	memory must be cleared in order to modify settings maxvar, min_memory, max_memory
	and segmentsize. Clearing all data from working memory is therefore the default.{p_end}
{synopt :{cmdab:quietly}}includes quietly tags in the dofile, so that the dofile runs without displaying output.{p_end}
{synopt :{cmdab:cust:om(}{it:string}{cmd:)}}allows the user to enter custom lines
of code to be added to the dofile this command creates.{p_end}
{synopt :{cmdab:setmem(}{it:string}{cmd:)}}allows the user to enter a custom memory
value for users that are using Stata 11. This value must be an integer followed
by the letter B, K, M or G. The default if omitted is 50M. Cannot be used if
versionnumber() is set to version 12.0 or more recent.{p_end}
{synoptline}

{marker desc}{...}
{title:Description}

{pstd}{cmdab:ieboilstart} creates a dofile for a project that includes a sections of standardized
	code meant to be included by all users for that project. Such standardized code is
	usually referred to as boilerplate code, and that is where {cmdab:ieboilstart} lends
	it's name from. Some of the boilerplate code is meant to harmonize preference
	settings across users (for example, {help set varabbrev:varabbrev}), and
	some settings are meant to mitigate the risk that different versions of Stata
	behave differently (for example, {help version:version}).

{pstd}A command like this is next to impossible to make comprehensive, so the ambition
	is mostly to provide an easy option to generate advance settings that are much
	better than having no boilerplate code at all. Suggestions for additions or improvements
	are very welcomed. See the {help ieboilstart##auth:author} section for contact details.

{pstd}All of these settings are very common in the Stata community, and the default
	values used are the values that are standard in boilerplate code for dofiles written
	for Impact Evaluations at World Bank DIME. For very good reasons, Stata has restrictions
	on what settings user written commands can modify, and this is the reason that there
	are two parts to specifying this command and why it is important to use {cmd:include} when
	executing the dofile generated.

{marker comp}{...}
{title:Compatibility Across Different Stata:}

{pstd}The first part of {cmdab:ieboilstart} generates a dofile with the most
	compatibility practically possible between Stata 11.0-14.1, Stata Small/IC/SE/MP and Stata for
	PC/Mac/Linux. {it:Compatibility} does not mean an absolute guarantee that all code will always
	work the same in different types of Stata. {it:Compatibility} here means that the risk of code working differently
	in different types of Stata is reduced. {it:Compatibility} here also means that the
	dofile includes if-statements skipping settings for users with other Stata types
	that would otherwise have generated an error. If possible it instead offers an alternative settings that works for that Stata type.

{pstd}In addition to version control, {cmdab:ieboilstart} allows a project to 	standardize user preference settings such as {help set varabbrev:varabbrev} that 		can cause code to not be compatiable across users.

{pstd}The second part of {cmdab:ieboilstart} applies those settings. The first part
	does not set any settings. The second part can be repeated multiple times after
	the dofile is generated in the first part.

{title:Important Details on Version Setting:}

{pstd}Impact Evaluations and other research projects often span over several
	years, which means that the same dofile is likely to run in different versions
	of Stata. Stata provides an method to reduce the risk that this leads to unstable
	results. See {help version:version} settings for more details. This method is included in {cmdab:ieboilstart}, however, {cmd:version} is intended for making code written in Stata 11 to work
	in Stata 14 and not the other way around. Code written in Stata 14 set to version
	11 might still behave differently. Setting the version is still best practice,
	and the dofile from {cmdab:ieboilstart} can be used as documentation to what
	settings were applied.

{pstd}{hi:Warning 1:} Any dofiles containing randomization {ul:{hi:MUST}} set the version number
	as Stata occasionally makes updates to it's randomization algorithm. A dofile including random assignment
	or random sampling is therefore not necessarily stable across different versions of Stata,
	unless the dofile has a version number explicitly set in the beginning of the file.

{pstd}{hi:Warning 2:} Note that version settings has the same scope as a local. That means that
	as soon as a dofile comes to an end (after running all the sub-dofiles that the dofile calls)
	the Stata version is restored to its original value. Hence, DIME recommended best practice is to set the version
	number in the master dofile for each project (by including the dofile generated by {cmdab:ieboilstart})
	and in any individual dofile that uses on randomization. It would only rarely be necessary to set version number in each
	individual dofile if the version number is set in the master dofile, in most projects this would
	create a lot of work to a very small gain. If {cmdab:ieboilstart} is included in the master dofile,
	then it would be sufficient to use the command {help version:version} in individual dofiles
	with randomization instead of running the dofile generated by {cmdab:ieboilstart}.

{title:Details on Memory Settings:}

{pstd}In Stata versions before Stata 12, memory was assigned statically from the
	computer memory, meaning that there was a fixed amount of memory assigned to Stata
	regardless if required it or not. Stata would crash if it went over that fixed limit
	when for example increasing the data set or running a complex calculation. In Stata
	12 and more recent versions, this is done dynamically, meaning that Stata is assigned
	a little bit of memory when it is started and assigned additional memory dynamically
	as needed. The only memory limit is the hardware limits on the computer it is running
	on.

{pstd}The fixed memory in Stata 11 was assigned by the command {cmdab:set memory}. This
	command is simply ignored in Stata 12 or later. Instead the dynamic memory setting
	can be fine tuned with {cmdab:min_memory}, {cmdab:max_memory}, {cmdab:niceness} and
	{cmdab:segmentsize}, although even highly advanced users rarely have to worry about these settings as long as they are set to the recommended default values
	(which this command ensures that they are).

{p2colset 5 22 24 2}
{p2col : Memory Settings}Short explanation{p_end}
{p2line}
{pstd}{it: Basic Settings:}{p_end}
{p2col :{cmdab:set maxvar}}sets the maximum number of variables allowed. The
	default value is 32,767 the maximum allowed in Stata MP or SE. A lower maximum number can manually be set by the option {cmdab:maxvar()}. This setting is skipped using an if-statement if the dofile is executed in Stata Small or IC. See {help set maxvar:set maxvar}.{p_end}
{p2col :{cmdab:set matsize}}sets the maximum number of variables that can be included in estimation commands such as {cmd:regress}. The {cmdab:ieboilstart} default value is 400 which is the default value for Stata. The maximum number can manually be set by the option {cmdab:matsize()} as long as the number does not violate the limitations in your version of Stata. See {help set matsize:set matsize}.{p_end}
{break}
{pstd}{it: Dynamic Memory Settings (see {help memory:memory} for details and reasons for default values. Few users ever need to change these values):}{p_end}
{p2col :{cmdab:set min_memory}}sets a lower bound for the amount of memory assigned to Stata. The default value is no lower bound.{p_end}
{p2col :{cmdab:set max_memory}}sets an upper bound for the amount of memory assigned to Stata. The default is as much as the hardware of the computer allows.{p_end}
{p2col :{cmdab:set niceness}}defines how quickly Stata releases unused memory back to the computer{p_end}
{p2col :{cmdab:set segmentsize}}defines how large bundles of data is assigned each time
			Stata request more memory. Too large bundles make Stata occupy an
			unnecessary large part of the computer's memory (that otherwise could
			have been used by other applications), and too small bundles make
			Stata frequently consume processing power requesting new bundles.{p_end}
{break}
{pstd}{it: Static Memory Settings (only applicable in Stata 11)}{p_end}
{p2col :{cmdab:set memory}}sets the amount of static memory assigned to Stata. {p_end}
{p2line}

{pstd}{hi:{ul:Other Settings:}}{break}The other settings are included as they are either very
	commonly preferred or reduces the risk of errors for users that do not yet fully understand
	the implication of setting these settings to other values than what is recommended. These
	settings can be reverted to personal preferences after running the dofile created
	by {cmdab:ieboilstart} or by using the {cmd:custom()} option.{p_end}
{p2colset 5 24 26 2}
{p2col : Other Settings}Short explanation{p_end}
{p2line}
{p2col :{cmdab:set more off}}disables the default setting that Stata stops and
	waits for the user to press any key each time the output window is full. Long
	dofiles would take a very long time to run and require constant attention from
	the user without this setting. Most Stata users always disable the default
	which is {cmdab:set more on}. See {help set more:set more}.{p_end}
{p2col :{cmdab:pause on}}allows the usage of the command {cmdab:pause} which can
	be very useful during debugging. See {help pause:pause}.{p_end}
{p2col :{cmdab:set varabbrev off}}allows users to abbreviate variable names
		similarly to command names such as gen for generate and reg for regress.
		However, while command abbreviation has strict rules constant across data sets, users, and
		Stata versions; variable name abbreviation does not have the same strict rules
		and consistency. While enabling variable abbreviation can speed up coding,
		it is an error-prone technique unless all users using a dofile with
		variable abbreviations organize their coding practices exactly the same
		way. See {help set varabbrev:set varabbrev} for more details and carfully
		consider this caution before enabling variable abbreviations in a
		collaborative dofile.{p_end}
{p2line}

{title:Options}

{phang}{cmdab:v:ersionnumber(}{it:string}{cmd:)} sets a version number of
	Stata for the rest of the dofile. This option ensures that the dofile will
	generates a consistent result regardless of which version of Stata that is used.
	The version number should be set to the oldest version used by anyone
	in the team that will work on this dofile. However, a too low number might
	risk that some commands will not work as expected in more recent versions. Best
	practice is to keep the same version number throughout a project, unless there is something specific
	to a newer version that is required for any dofile. Only major and recent
	versions are allowed in order to reduce errors and complexity. The valid versions
	are 11.0, 11.1, 11.2, 12.0, 12.1, 13.0, 13.1, 14.0 and 14.1. All
	versions of Stata can be set to run any older version of Stata but not a
	newer. It is recommended to use a .1 over a .0 version. .1 is free of charge
	if you already have the corresponding .0 and .1 includes bug fixes to the
	functions introduced in .0{p_end}

{phang}{cmdab:maxvar(}{it:numlist}{cmd:)} manually sets the maximum number of
	variables allowed in a data set. The default is to set the number to the highest
	allowed. Reducing this number can occasionally imrpove performance, but modern
	computers running Impact Evaluations analysis are more likely to
	face the problem of too few variables allowed than running out of
	memory. The maximum number allowed is 2047 in Stata IC and 32,767 in Stata MP or SE.{p_end}

{phang}{cmdab:matsize(}{it:numlist}{cmd:)} manually sets the maximum number of
	variables allowed in estimation commands, for example {help reg:regress}.
	The default is to set the number to the highest allowed in your version of Stata.
	Reducing this number can occasionally imrpove performance, but modern
	computers running Impact Evaluations analysis are more likely
	to run into problems allowing too few variables than running out of memory.
	Although, this is more likely the case with {cmdab:maxvar} than
	with {cmdab:matsize}. The maximum number allowed is 800 in Stata IC and 11,000 in Stata
	MP or SE.{p_end}

{phang}{cmdab:noclear} prevents the command from clearing/deleting the data set
	in working memory. No data may be in working memory in order to modify
	settings for maxvar, min_memory, max_memory and segmentsize. That is why the default
	is to clear the data set stored in working memory. Working memory is your RAM
	memory so no data saved to your hard drive will ever be deleted by this command.
	This command is intended to be placed at the very top of a dofile, so the
	data needed could be loaded into memory after running ieboilstart. For the
	reasons above, {cmdab:noclear} and {cmdab:maxvar()} cannot be combined.{p_end}

{phang}{cmd:quietdo} encapsulates the do-file created in a {help quietly} block so
	that the do-file runs without displaying any output.{p_end}

{phang}{cmdab:cust:om(}{it:string}{cmd:)} allows the user to add one or multiple custom lines of code
	to the do-file. Each line of code should be seperated with a "@". See example 4
	below for more details.{p_end}

{title:Examples}

{pmore}In all examples below {it:localname1} and {it:localname2} may be changed
	to any other valid macro name.

{pstd}{hi:Example 1.}

{pmore}{inp:ieboilstart using }{it:myfile}{inp:.do, versionnumber(11.1)}
{break}{cmdab:include} "`r(ieboil_dofile)'"

{pmore}In the example above, a dofile named myfile.do will be saved to the current
	directory (see {help cd:help cd}). After running iboil_settings.do the rest of the code
	will be run as if the version of Stata was version 11.1. That means that anyone who
	bought or upgraded Stata after June 2010 can use this dofile and all commands will
	behave identically for all those users. Maxvar and matsize have been set to
	highest allowed values (note that this might differ across users) and advanced
	memory settings is set to Stata's recommended values. More is set to off,
	pause is on and variable abbreviation is disabled.

{pstd}{hi:Example 2.}

{pmore}{inp:global dofile_folder "C:\User\Example Project Folder\dofiles"}

{pmore}{inp:ieboilstart using "$dofile_folder/ieboil_settings.do", versionnumber(13.1) maxvar(20000)}
{break}{cmdab:include} "`r(ieboil_dofile)'"

{pmore}In the example above, a dofile named ieboil_settings.do will be saved to the
	folder that the global {it:dofile_folder} is pointing to. The rest of the code will be run as if the
	version of Stata was version 13.1. That means that anyone who bought or upgraded
	Stata after October 2013 can use this dofile. Matsize has been set to
	highest allowed values, but maxvar is restricted to 20,000 variables. Advanced
	memory settings is set to Stata's recommended values. More is set to off,
	pause is on and variable abbreviation is disabled.

{pstd}{hi:Example 3.}

{pmore}If the same settings as in example 2 needs to be applied somewhere else in
	the code, then the do-file can be referenced by its name like below:

{pmore}{cmdab:include} "$dofile_folder/ieboil_settings.do"

{pstd}{hi:Example 4.}

{pmore}{inp:ieboilstart using "$dofile_folder/ieboil_settings.do", versionnumber(13.1) custom(ssc install estout @ ssc install winsor)}
{break}{cmdab:include} "`r(ieboil_dofile)'"

{pmore}In the example above, two lines of code is manually entered to the do-file.

{title:Acknowledgements}

{phang}I would like to acknowledge the help in testing and proofreading and suggestions I
	received in relation to this command and help file from (in alphabetic order):{p_end}
{pmore}Michell Dong{break}John Dundas{break}Paula Gonzales{break}Seungmin Lee{break}Srujith Lingala{break}William Lisowski{break}Daniel Klein

{marker auth}{...}
{title:Author}

{phang}Kristoffer Bj�rkefur, The World Bank, DECIE

{phang}Please send bug-reports, suggestions and requests for clarifications
		 writing "ietools ieboilstart" in the subject line to:{break}
		 kbjarkefur@worldbank.org

{phang}You can also see the code, make comments to the code, see the version
		 history of the code, and submit additions or edits to the code through
		 the github repository of ietoolkit:{break}
		 {browse "https://github.com/worldbank/ietoolkit"}

{smcl}
{* 1 Nov 2016}{...}
{hline}
help for {hi:ieboilstart}
{hline}

{title:Title}

{phang2}{cmdab:ieboilstart} {hline 2} Creates a dofile that harmonizes the settings
accross team members in the same project to the longest extent technically possible.

{phang2}{hi:DISCLAIMER} {hline 1} There are several technical reasons why it is
impossible to guarantee that differnt types of Stata (version number, Small/IC/SE/MP
or PC/Mac/Linux) work exactly the same in every possible context. However, this command
gathers best practices used accross the Stata community to mitigate the risk of behaving
differntly. See more details {help ieboilstart##comp:below}.

{title:Syntax}

{pstd}Note that due to technical requirements in Stata, there are two crucial details on
how to use this command correctly.{p_end}

{pstd}The most important detail is to execute the dofile generated by using {cmd:include} and
not {cmd:do} or {cmd:run}. Otherwise version number, which is probably
the most important part of this command, is not set correctly.{p_end}

{pstd}The second detail is that both parts below needs to be executed. The first part only
generates the dofile with all recommended settings, and the second part execute them. The
second part can be done multiple times after the first part is done once.{p_end}

{phang2}{it:First part:}{break}
{cmdab:ieboilstart} using {help filename :filename}.do
, {cmdab:v:ersionnumber(}{it:string}{cmd:)}  [{cmdab:maxvar(}{it:numlist}{cmd:)}
{cmdab:matsize(}{it:numlist}{cmd:)} {cmd:noclear} {cmdab:qui:etdo}
{cmdab:cust:om(}{it:string}{cmd:)} {cmdab:setmem(}{it:string}{cmd:)}]

{phang2}{it:Second part if following immediately after main part (recommended):}{break}
{cmdab:include} "`r(ieboil_dofile)'"

{phang2}{it:Second part anywhere in a dofile:}{break}
{cmdab:include} {help filename :filename}{it:.do}

{pstd}See more details on why two parts are required and why {cmd:include} must
be used instead of {cmd:do} or {cmd:run}.

{marker opts}{...}
{synoptset 20}{...}
{synopthdr:options}
{synoptline}
{synopt :{cmdab:v:ersionnumber(}{it:string}{cmd:)}}sets a stable version of Stata
	that always applies regardless of which [newer] version of Stata the
	dofile is executed in after running this command.{p_end}
{synopt :{cmdab:maxvar(}{it:numlist}{cmd:)}}manually sets the maximum number of
	variables allowed in a data set. The default if omitted is 32767.{p_end}
{synopt :{cmdab:matsize(}{it:numlist}{cmd:)}}manually sets the maximum number of
	variables allowed in an estimation command, for example {help regress:regress}.
	The default if omitted is 400.{p_end}
{synopt :{cmdab:noclear}}prevents the command from clearing data in memory. The
	memory must be cleared in order to modify settings maxvar, min_memory, max_memory
	and segmentsize. Clearing all data from working memory is therefore the default.{p_end}
{synopt :{cmdab:quietly}}includes quietly tags in the dofile, so that the dofile runs without displaying output.{p_end}
{synopt :{cmdab:cust:om(}{it:string}{cmd:)}}allows the user to enter custom lines
of code to be added to the dofile this command creates.{p_end}
{synopt :{cmdab:setmem(}{it:string}{cmd:)}}allows the user to enter a custom memory
value for users that are using Stata 11. This value must be an integer followed
by the letter B, K, M or G. The default if omitted is 50M. Cannot be used if
versionnumber() is set to version 12.0 or more recent.{p_end}
{synoptline}

{marker desc}{...}
{title:Description}

{pstd}{cmdab:ieboilstart} creates a dofile for a project that includes a sections of standardized
	code meant to be included by all users for that project. Such standardized code is
	usually referred to as boilerplate code, and that is where {cmdab:ieboilstart} lends
	it's name from. Some of the boilerplate code is meant to harmonize preference
	settings across users (for example, {help set varabbrev:set varabbrev}), and
	some settings are meant to mitigiate the risk that different versions of Stata
	behave differently (for example, {help version:version}).

{pstd}A command like this is next to impossible to make comprehensive, so the ambition
	is mostly to provde an easy option to generate advance settings that are much
	better than having no boilerplate code at all. Suggestions for additions or improvments
	are very welcomed. See the {help ieboilstart##auth:author} section for contact details.

{pstd}All of these settings are very common in the Stata community, and the default
	values used are the values that are standard in boilerplate code for dofiles written
	for Impact Evaluations at World Bank DIME. For very good reasons, Stata has restrictions
	on what settings userwritten commands can modify, and this is the reason that there
	are two parts to specifying this command and why it is important to use {cmd:include} when
	exectuing the dofile generated.

{marker comp}{...}
{title:Compatibility Accross Different Stata:}

{pstd}The first part of {cmdab:ieboilstart} generates a dofile with the most
	compatibility practically possible between Stata 11.0-14.1, Stata Small/IC/SE/MP and Stata
	PC/Mac/Linux. {it:Compatibility} does not mean an absolute gurantee that all code will always
	work the same in different types of Stata. {it:Compatibility} here means that the risk of code working differently
	in different types of Stata is reduced. {it:Compatibility} here also means that the
	dofile includes if-statments skipping settings for users with other Stata types
	that would otherwise have generated an error. If possible it instead offers an alternative
	settings that works for that Stata type.

{pstd}The second part of {cmdab:ieboilstart} applies those settings. The first part
	does not set any settings. The second part can be repeted multiple times after
	the dofile is generated in the first part.

{title:Important Details on Version Setting:}

{pstd}Impact Evaluations and other research projects often span over several
	years, which means that the same dofile is likely to run in different versions
	of Stata. Stata provides an method to reduce the risk that this leads to unstable
	results. See {help version:version settings}. This method is included in {cmdab:ieboilstart}.
	However, {cmd:version} is intended for making code written in Stata 11 to work
	in Stata 14 and not the other way around. Code written in Stata 14 set to version
	11 might still behave differently. Setting the version is still best practice,
	and the dofile from {cmdab:ieboilstart} can be used as documentation to what
	settings were applied.

{pstd}{hi:Warning 1:} Any dofiles containing randomization {ul:{hi:MUST}} set the version number
	as Stata occasionally makes updates to it's randomization algorithm. A dofile including random assignment
	or random sampling is therefore not necessarily stable across different versions of Stata,
	unless the dofile has a version number explicitly set in the beginning of the file.

{pstd}{hi:Warning 2:} Note that version settings has the same scope as a local. That means that
	as soon as a dofile comes to an end (after running all the sub-dofiles that the dofile calls)
	the Stata version is restored to its original value. Hence, DIME recommended best practice is to set the version
	number in the master dofile for each project (by including the dofile generated by {cmdab:ieboilstart})
	and in any individual dofile that uses on randomization. It would only rarely be necessary to set version number in each
	individual dofile if the version number is set in the master dofile, in most projects this would
	create a lot of work to a very small gain. If ieboilstart is included in the master dofile,
	then it would be sufficient to use the command {help version:version} in individual dofiles
	with randomization instead of running the dofile generated by ieboilstart.

{title:Details on Memory Settings:}

{pstd}Memory Settings are divided into basic and advanced
	settings (see the list below). Even highly advanced users rarely have to worry about the advanced
	settings as long as they are set to the recommended default values (which
	this command ensures that they are).

{pstd}The basic settings will be set to the maximum value allowed in your
	version of Stata unless option {cmdab:maxvar()} or option {cmdab:matsize()} are specified.
	If you are running Stata on an old computer, or if you have to simultaneously
	run memory-intensive programs, then you can set a lower value than the
	maximum using the {cmdab:maxvar()} and {cmdab:matsize()} options. However,
	the difference that makes on a modern computer is usually marginal.

{pstd}In earlier versions of Stata memory was assigned statically from the
	computer memory, meaning that Stata could only use as much memory as the
	default value of the version of Stata used, or a value explicitly set by the
	user. This is no longer the case as Stata gets memory assigned dynamically.
	The operative system assigns a small amount of the computer's memory when Stata starts,
	and increase the assigned memory automatically when needed. The command {cmdab:set memory}
	that all users previously had to be aware of is therefore now ignored by
	Stata. {cmdab:set memory} was replaced with {cmdab:set min_memory} and
	{cmdab:set max_memory} but as memory is now assigned dynamically, those are
	only relevant to the very advanced user in very specific contexts.{p_end}
{p2colset 5 22 24 2}
{p2col : Memory Setting}Short explanation{p_end}
{p2line}
{pstd}{it: Basic Settings:}{p_end}
{p2col :{cmdab:set maxvar}}sets the maximum number of variables allowed. The
	default value is the maximum allowed in your version of Stata; 2047 in Stata
	IC and 32,767 in Stata MP or SE. The maximum number can manually be set by the
	option {cmdab:maxvar()} as long as the number does not violate the limitations
	in your version of Stata. See {help set maxvar:set maxvar}{p_end}
{p2col :{cmdab:set matsize}}sets the maximum number of variables allowed in a
	regression or in any other of Stata's estimation commands. The default value is
	the maximum allowed in your version of Stata; 800 in Stata IC and 11,000 in
	Stata MP or SE. The maximum number can manually be set by the option {cmdab:matsize()}
	as long as the number does not violate the limitations in your version of
	Stata. See {help set matsize:set matsize}{p_end}
{break}
{pstd}{it: Advanced Settings:}{p_end}
{pstd}All advanced settings are set to the default values described here {help memory:memory}{p_end}
{p2col :{cmdab:set min_memory}}sets a lower bound for the dynamic memory assignment{p_end}
{p2col :{cmdab:set max_memory}}sets an upper bound for the dynamic memory assignment{p_end}
{p2col :{cmdab:set niceness}}defines how quickly Stata releases unused memory back to the computer{p_end}
{p2col :{cmdab:set segmentsize}}defines how large bundles of data is assigned each time
			Stata request more memory. Too large bundles make Stata occupy an
			unnecessary large part of the computer's memory (that otherwise could
			have been used by other applications), and too small bundles make
			Stata frequently consume processing power requesting new bundles.{p_end}
{p2line}

{pstd}{hi:{ul:Other Settings:}}{break}The other settings are included as they are either very
	commonly preferred or reduces the risk of errors for users that do not yet fully understand
	the implication of setting these settings to other values than what is recommended. These
	settings can be reverted to personal preferences after running the dofile created
	by {cmdab:ieboilstart} or by using the {cmd:custom()} option.{p_end}
{p2colset 5 24 26 2}
{p2col : Other Settings}Short explanation{p_end}
{p2line}
{p2col :{cmdab:set more off}}disables the default setting that Stata stops and
	waits for the user to press any key each time the output window is full. Long
	dofiles would take a very long time to run and require constant attention from
	the user without this setting. Most Stata users always disable the default
	which is {cmdab:set more on}. See {help set more:set more}.{p_end}
{p2col :{cmdab:pause on}}allows the usage of the command {cmdab:pause} which can
	be very useful during debugging. See {help pause:pause}.{p_end}
{p2col :{cmdab:set varabbrev off}}allows users to abbreviate variable names
		similarly to command names such as gen for generate and reg for regress.
		However, while command abbreviation has strict rules constant across data sets, users, and
		Stata versions; variable name abbreviation does not have the same strict rules
		and consistency. While enabling variable abbreviation can speed up coding,
		it is an error-prone technique unless all users using a dofile with
		variable abbreviations organize their coding practices exactly the same
		way. See {help set varabbrev:set varabbrev} for more details and carfully
		consider this caution before enabling variable abbreviations in a
		collaborative dofile.{p_end}
{p2line}

{title:Options}

{phang}{cmdab:v:ersionnumber(}{it:string}{cmd:)} sets a version number of
	Stata for the rest of the dofile. This option ensures that the dofile will
	generates a consistent result regardless of which version of Stata that is used.
	The version number should be set to the oldest version used by anyone
	in the team that will work on this dofile. However, a too low number might
	risk that some commands will not work as expected in more recent versions. Best
	practice is to keep the same version number throughout a project, unless there is something specific
	to a newer version that is required for any dofile. Only major and recent
	versions are allowed in order to reduce errors and complexity. The valid versions
	are 11.0, 11.1, 11.2, 12.0, 12.1, 13.0, 13.1, 14.0 and 14.1. All
	versions of Stata can be set to run any older version of Stata but not a
	newer. It is recommended to use a .1 over a .0 version. .1 is free of charge
	if you already have the corresponding .0 and .1 includes bug fixes to the
	functions introduced in .0{p_end}

{phang}{cmdab:maxvar(}{it:numlist}{cmd:)} manually sets the maximum number of
	variables allowed in a data set. The default is to set the number to the highest
	allowed. Reducing this number can occasionally imrpove performance, but modern
	computers running Impact Evaluations analysis are more likely to
	face the problem of too few variables allowed than running out of
	memory. The maximum number allowed is 2047 in Stata IC and 32,767 in Stata MP or SE.{p_end}

{phang}{cmdab:matsize(}{it:numlist}{cmd:)} manually sets the maximum number of
	variables allowed in estimation commands, for example {help reg:regress}.
	The default is to set the number to the highest allowed in your version of Stata.
	Reducing this number can occasionally imrpove performance, but modern
	computers running Impact Evaluations analysis are more likely
	to run into problems allowing too few variables than running out of memory.
	Although, this is more likely the case with {cmdab:maxvar} than
	with {cmdab:matsize}. The maximum number allowed is 800 in Stata IC and 11,000 in Stata
	MP or SE.{p_end}

{phang}{cmdab:noclear} prevents the command from clearing/deleting the data set
	in working memory. No data may be in working memory in order to modify
	settings for maxvar, min_memory, max_memory and segmentsize. That is why the default
	is to clear the data set stored in working memory. Working memory is your RAM
	memory so no data saved to your hard drive will ever be deleted by this command.
	This command is intended to be placed at the very top of a dofile, so the
	data needed could be loaded into memory after running ieboilstart. For the
	reasons above, {cmdab:noclear} and {cmdab:maxvar()} cannot be combined.{p_end}

{phang}{cmd:quietdo} encapsulates the do-file created in a {help quietly} block so
	that the do-file runs without displaying any output.{p_end}

{phang}{cmdab:cust:om(}{it:string}{cmd:)} allows the user to add one or multiple custom lines of code
	to the do-file. Each line of code should be seperated with a "@". See example 4
	below for more details.{p_end}

{title:Examples}

{pmore}In all examples below {it:localname1} and {it:localname2} may be changed
	to any other valid macro name.

{pstd}{hi:Example 1.}

{pmore}{inp:ieboilstart using }{it:myfile}{inp:.do, versionnumber(11.1)}
{break}{cmdab:do} "`r(ieboil_dofile)'"

{pmore}In the example above, a dofile named myfile.do will be saved to the current
	directory (see {help cd:help cd}). After running iboil_settings.do the rest of the code
	will be run as if the version of Stata was version 11.1. That means that anyone who
	bought or upgraded Stata after June 2010 can use this dofile and all commands will
	behave identically for all those users. Maxvar and matsize have been set to
	highest allowed values (note that this might differ across users) and advanced
	memory settings is set to Stata's recommended values. More is set to off,
	pause is on and variable abbreviation is disabled.

{pstd}{hi:Example 2.}

{pmore}{inp:global dofile_folder "C:\User\Example Project Folder\dofiles"}

{pmore}{inp:ieboilstart using "$dofile_folder/ieboil_settings.do", versionnumber(13.1) maxvar(20000)}
{break}{cmdab:do} "`r(ieboil_dofile)'"

{pmore}In the example above, a dofile named ieboil_settings.do will be saved to the
	folder that the global {it:dofile_folder} is pointing to. The rest of the code will be run as if the
	version of Stata was version 13.1. That means that anyone who bought or upgraded
	Stata after October 2013 can use this dofile. Matsize has been set to
	highest allowed values, but maxvar is restricted to 20,000 variables. Advanced
	memory settings is set to Stata's recommended values. More is set to off,
	pause is on and variable abbreviation is disabled.

{pstd}{hi:Example 3.}

{pmore}If the same settings as in example 2 needs to be applied somewhere else in
	the code, then the do-file can be referenced by its name like below:

{pmore}{cmdab:do} "$dofile_folder/ieboil_settings.do"

{pstd}{hi:Example 4.}

{pmore}{inp:ieboilstart using "$dofile_folder/ieboil_settings.do", versionnumber(13.1) custom(ssc install estout @ ssc install winsor)}
{break}{cmdab:do} "`r(ieboil_dofile)'"

{pmore}In the example above, two lines of code is manually entered to the do-file.

{title:Acknowledgements}

{phang}I would like to acknowledge the help in testing and proofreading and suggestions I
	received in relation to this command and help file from (in alphabetic order):{p_end}
{pmore}Michell Dong{break}John Dundas{break}Paula Gonzales{break}Seungmin Lee{break}Srujith Lingala{break}William Lisowski{break}Daniel Klein

{marker auth}{...}
{title:Author}

{phang}Kristoffer Bjrkefur, The World Bank, DECIE

{phang}Please send bug-reports, suggestions and requests for clarifications
		 writing "ietools ieboilstart" in the subject line to:{break}
		 kbjarkefur@worldbank.org

{phang}You can also see the code, make comments to the code, see the version
		 history of the code, and submit additions or edits to the code through
		 the github repository of ietoolkit:{break}
		 {browse "https://github.com/worldbank/ietoolkit"}