iedropone : first final draft of helpfile

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

{title:Title}

{phang2}{cmdab:iedropone} {hline 2} Same function as {help drop} but prevents that additional observation are unintentionally dropped

{title:Syntax}

{phang2}
{cmdab:iedropone} [if] , {cmdab:n:umobs(}{it:integer}{cmd:)}
	{cmdab:mvar(}{it:varname}{cmd:)} {cmdab:mval(}{it:list of values}{cmd:)}
	{cmd:zerook}]

{marker opts}{...}
{synoptset 22}{...}
{synopthdr:options}
{synoptline}
{synopt :{cmdab:n:umobs(}{it:integer}{cmd:)}}Number of observations that is allowed to be dropped. Default is 1.{p_end}
{synopt :{cmd:zerook}}Allows that no observation is dropped.{p_end}
{synopt :{cmdab:mvar(}{it:varname}{cmd:)}}Variable for which multiple values should be dropped. Must be used together with {cmdab:mval()}.{p_end}
{synopt :{cmdab:mval(}{it:list of values}{cmd:)}}The list of values in {cmdab:mvar()} that should be dropped. Must be used together with {cmdab:mvar()}.{p_end}
{synoptline}

{marker desc}
{title:Description}

{pstd}{cmdab:iedropone} has the identical purpose as {help drop} when dropping
	observations. However, {cmdab:iedropone} safeguards that no additional
	observations are unintentionally dropped, or that changes are made to the
	data so that the observations that are suppoed to be dropped are no longer dropped.

{pstd}{cmdab:iedropone} checks that no more or fewer observations than intended are
	dropped. For example, in the case that one observation has been identified to
	be dropped, then we want to make sure that when re-running the do-file only
	that observations is dropped even if more observations are added to that data
	set or changed in any other way.

{pstd}While the default is 1, {cmdab:iedropone} allows the user to set another number
	of observation that should exactly be dropped. It also alows for dropping an exact
	number of observations for multiple values in a variable.

{marker optslong}
{title:Options}

{phang}{cmdab:n:umobs(}{it:integer}{cmd:)}} this allows the user to set the
	number of observation that should be dropped. The default is 1 but any
	positive integer can be used. The command throws an error if any other number
	of observations are dropped.

{phang}{cmd:zerook} allows that no observations are dropped. The default is that an error is thrown if no observations are dropped.

{phang}{cmdab:mvar(}{it:varname}{cmd:)} and {cmdab:mval(}{it:list of values}{cmd:)} allows
	that multiple values in one variable are dropped. These two option must be used together.
	The command loops over the values in {cmd:mval()} and drop the observations that has the
	looped value in {cmd:mvar()} and satisfies the {it:if} condition. For example:{p_end}

{pmore}{inp:iedroponce if village == 100 , mvar(household_id) mval(21 22 23)}

{pmore}is identical to:

{pmore}{inp:iedroponce if village == 100 & household_id == 21}{break}
{inp:iedroponce if village == 100 & household_id == 22}{break}
{inp:iedroponce if village == 100 & household_id == 23}{break}

{pmore}The default is that exactly one observation should be dropped for each
	value in {cmd:mval()} unless {cmd:numobs()} or {cmd:zerook} is used. If those
	options are used then, then they apply to all values in {cmd:mval()} seperately.

{phang}{cmdab:mval(}{it:list of values}{cmd:)}, see {cmdab:mvar(}{it:varname}{cmd:)} above.

{title:Examples}

{pstd} {hi:Example 1.}

{pmore}{inp:iedropone if household_id == 712047}

{pmore}Let's say that we have identified the household with the ID 712047 to be
	incorrect and it should be dropped. Identical to {inp:drop if household_id == 712047}
	but it will test that exactly one observation is dropped each time the do-file runs.
	This guarantees that we will get an error message that no observation is dropped
	if someone makes a change to the ID. Otherwise we would unknowingly keep this
	incorrect observation in our data set.

	Similarly, if a new observation is added that is the correct household with ID 712047,
	then both observation would be dropped without warning if we would have
	used {inp:drop if household_id == 712047}. {cmd:iedropone} will make sure that
	our drop condition are applied as intended even if the data set is changed.

{pstd} {hi:Example 2.}

{pmore}{inp:iedropone if household_id == 712047 & household_head == "Bob Smith"}

{pmore}Let's say we have added a new houshold with the ID 712047. In order to
	drop only one of those observations we must expand the if condition to
	indicate which one of them we want to drop.

{pstd} {hi:Example 3.}

{pmore}{inp:iedropone if household_id == 712047, numobs(2)}

{pmore}Let's say we added a new houshold with the ID 712047 but we want to drop
	exactly both of them, then we can use the option {cmd:numobs()} like above.
	The command will now throw an error if not exactly two observations have the
	household ID 712047.

{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}Mrijan Rimal{break}

{title:Author}

{phang}Kristoffer Bjarkefur, The World Bank, DECIE

{phang}Please send bug-reports, suggestions and requests for clarifications
		 writing "ietools iedropone" 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:iedropone}
{hline}

{title:Title}

{phang2}{cmdab:iedropone} {hline 2} Same function as {help drop} but prevents that additional observation are unintentionally dropped

{title:Syntax}

{phang2}
{cmdab:iedropone} [if] , {cmdab:n:umobs(}{it:integer}{cmd:)}
	{cmdab:mvar(}{it:varname}{cmd:)} {cmdab:mval(}{it:list of values}{cmd:)}
	{cmd:zerook}]

{marker opts}{...}
{synoptset 22}{...}
{synopthdr:options}
{synoptline}
{synopt :{cmdab:n:umobs(}{it:integer}{cmd:)}}Number of observations that is allowed to be dropped. Default is 1.{p_end}
{synopt :{cmdab:mvar(}{it:varname}{cmd:)}}Variable for which multiple values should be dropped. Must be used together with {cmdab:mval()}.{p_end}
{synopt :{cmdab:mval(}{it:list of values}{cmd:)}}The list of values in {cmdab:mvar()} that should be dropped. Must be used together with {cmdab:mvar()}.{p_end}
{synopt :{cmd:zerook}}Allows that no observation is dropped.{p_end}
{synoptline}

{marker desc}
{title:Description}

{pstd}{cmdab:iedropone} has the identical purpose as {drop help} when dropping
	observations. However, {cmdab:iedropone} safeguards that no additional
	observations are unintentionally dropped, or that changes are made to that
	data that observations that are suppoed to be dropped are no longer dropped.

{pstd}{cmdab:iedropone} checks that no more or fewer observations than intended are
	dropped. For example, in the case that one observation has been identified to
	be dropped, then we want to make sure that when re-running the do-file only
	that observations is dropped even if more observations are added to that data
	set or changed in any other way.

{pstd}While the default is 1, {cmdab:iedropone} allows the user to set another number
	of observation that should exactly be dropped. It also alows for dropping an exact
	number of observations for multiple values in a variable.

{marker optslong}
{title:Options}

{phang}{cmdab:n:umobs(}{it:integer}{cmd:)}} this allows the user to set the
	number of observation that should be dropped. The default is 1 but any
	positive integer can be used. The command throws an error if any other number
	of observations are dropped.

{phang}{cmdab:mvar(}{it:varname}{cmd:)} indicates a variables where multiple
	values should be dropped. It must be exactly one observation for each value that is dropped, unless {cmd:

{phang}{cmdab:mval(}{it:list of values}{cmd:)}

{pmore}{cmd:zerook} allows that no observations are dropped. The default is that an error is thrown if no observations are dropped.

{title:Examples}

{pstd} {hi:Example 1.}

{pmore}{inp:iematch , grpdummy({it:tmt}) matchvar({it:p_hat})}

{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}Mrijan Rimal{break}

{title:Author}

{phang}Kristoffer Bjarkefur, The World Bank, DECIE

{phang}Please send bug-reports, suggestions and requests for clarifications
		 writing "ietools iematch" 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"}


iefodlers run file lightening seminar

iefodlers run file lightening seminar

	*Set standardized settings
	ieboilstart, v(11.1)
	`r(version)'

	*Folder globals
	global box 			"C:\Users\wb462869\Box Sync"
	global ief 			"$box\Stata\Stata work\Commands\ietoolkit"

	*Load the command
	do "$ief\functions.do"
	do "$ief\iefolder.do"

	*Set cd folder to catch and cd leakage
	cd "$ief\test\cdjunk"

	*Clean up the folder fomr last run
	do "$ief\deletefolder.do"
	cap deleteFolder "$projectABC\DataWork"

******************************************************************************

	*Global to the project fodler in box
	global projectABC	"$ief\test\testOutput\Project ABC Uganda"

	*Creat a new project
	iefolder new project , projectfolder("$projectABC")

	*Create a new folder called baseline
	iefolder new round baseline , projectfolder("$projectABC")

	*Create a new folder for endline with abbreviation EL
	iefolder new round endline 	, projectfolder("$projectABC") abb("EL")

	*Show example of test for imput
	iefolder new round baseline , projectfolder("$projectABC")

	*Show that it is scalabe
	iefolder new round test1 , projectfolder("$projectABC")
	iefolder new round test2 , projectfolder("$projectABC")
	iefolder new round test3 , projectfolder("$projectABC")

	ieboilstart, v(11.1)
	`r(version)'

	global box 			"C:\Users\wb462869\Box Sync"
	*global box			"C:\Users\Kristoffer\Box Sync"

	global ief 			"$box\Stata\Stata work\Commands\ietoolkit"
	global testProject	"$ief\test\testOutput\Project ABC Uganda"

	do "$ief\functions.do"
	do "$ief\iefolder.do"
	do "$ief\deletefolder.do"

	cd "$ief\test\cdjunk"

	*use cd to test if folder can be created

	********************************

	*local surveyRounds baseline endline kristoffer kewinowens

	********************************

	cap noi deleteFolder "$testProject\DataWork"

	*di `"   iefolder new project 		, projectfolder("$testProject")"'
	iefolder new project 		, projectfolder("$testProject")

	*di `"   iefolder new round baseline , projectfolder("$testProject") abb("BL")"'
	iefolder new round baseline , projectfolder("$testProject") abb("BL")

	*di `"   iefolder new round endline 	, projectfolder("$testProject") abb("EL")"'
	iefolder new round endline 	, projectfolder("$testProject") abb("EL")

	*di `"   iefolder new round endline 	, projectfolder("$testProject") abb("EL")"'
	*iefolder new round kristobal 	, projectfolder("$testProject")
	*iefolder new round kristoball 	, projectfolder("$testProject")
	*iefolder new round kristoballl , projectfolder("$testProject")
	*doedit "$projectfolder\mainMasterDofile.do"