iefolder : help last edits

iefolder : help last edits

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

{title:Title}

{phang2}{cmdab:iefolder} {hline 2} sets up project folders and master do-files according to World Bank DIME's standards.

{title:Syntax}

{pstd} {ul:When initially setting up the {hi:DataWork} folder in a new project:}

{phang2}{cmd:iefolder} new project, {cmdab:proj:ectfolder(}{it:directory}{cmd:)}

{pstd} {ul:When adding folders to and already existing {hi:DataWork} folder:}

{phang2}{cmd:iefolder} new {it:itemtype} {it:itemname} , {cmdab:proj:ectfolder(}{it:directory}{cmd:)}
	[{cmdab:abb:reviation(}{it:string}{cmd:)}]

{pmore}where {it:itemtype} is either {it:round} or {it:unitofobs}. See
	details on {it:itemtype} and {it:itemname} below.

{marker opts}{...}
{synoptset 22}{...}
{synopthdr:options}
{synoptline}
{synopt : {cmdab:proj:ectfolder(}{it:dir}{cmd:)}}The location of
	the project folder where the {hi:DataWork} folder should be
	created (new projects), or where it is located (new round and new unitofobs).{p_end}
{synopt : {cmdab:abb:reviation(}{it:string}{cmd:)}}Optional abbreviation
	of round name to be used to make globals shorter. Can only be used
	when {it:itemtype} is round.{p_end}
{synoptline}

{marker desc}{title:Description}

{pstd}{cmdab:iefolder} automates the process of setting up the folders and master do-files
	where all the data work will take place in a project folder. The folders set
	up will follow DIME's best practices outlined and explained here:
	{browse "https://dimewiki.worldbank.org/wiki/DataWork_Folder"} (This page
	is a part of a Wiki that we are in the final stage of getting approval to
	release externally, the page is until then unfortunately password protected.)

{pstd}In addition to setting up the {hi:DataWork} folder and its sub-folders, the
	command creates master do-files linking to all of these sub-folders. These
	master do-files are updated whenever more subfolders are added using this command.

{pstd}{ul:{hi:itemtypes}}. This command can create either a new DataWork folder or add folders to an
	existing DataWork folder. The existing DataWork folder must have been created
	with {cmd:iefolder} for the additions to work. There are two types of folders
	that can be added to an existing folder, {ul:round} and {ul:untiofobs}. See
	next paragraphs for descriptions.

{pstd}{hi:{it:round}} folders are folders specific to a data collection round, for example, {it:Baseline}, {it:Endline},
	{it:Follow Up} etc. When adding a new round, sub-folders are added to the DataWork
	folder in line with the best practice described here:
	{browse "https://dimewiki.worldbank.org/wiki/DataWork_Survey_Round"}. {cmd:iefolder} also
	creates a master do-file specific for this round with globals referencing the sub-folders
	specific to this round. {cmd:iefolder} is implemented so that you can keep working
	for years with your project in between adding folders. The command reads and perserves
	changes made manually to the DataWork folder and master do-file before making additions
	when adding a new round.

{pstd}{hi:{it:untiofobs}} folders are folders specific to a unit of observation,
	for example the master data set folder. Read more about master data sets and the folder structure
	this commands sets up for you at {browse "https://dimewiki.worldbank.org/wiki/Master_Data_Set"}. A
	master data folder for each new unit of observation is created in two places. Both in
	the MasterData folder in the DataWork folder, and in the MasterKeyID folder in the encrypted folder.

{marker optslong}{title:Options}

{phang}{cmdab:proj:ectfolder(}{it:dir}{cmd:)} should point to the same folder regardless
	of which {it:itemtype} is created. If {it:new project} is specified the file path should
	point to where DataWork should be created, and if {it:new round} or {it:new project} is
	specified, it should point to where DataWork was already created. See how the file path is
	the same both time when {cmd:iefolder} is called twice in Example 1 below.

{phang}{cmdab:abb:reviation(}{it:string}{cmd:)} can be used to shorten the globals created
	in the master do-files that point to the sub-folders to {it:round} folders. For example,
	if you create a new {it:round} called Baseline, as in Example 1, then a global to the
	DataSet folder called Baseline_dt will be created in the master do-file. If the
	abbreviation option would have been used, like in Example 2, then the global would
	have been called BL_dt.

{title:Examples}

{pstd}{hi:Example 1.}

{pmore}{inp:global projectFolder "C:\Users\Documents\DropBox\ProjectABC"}

{pmore}{inp:iefolder new project , projectfolder("$projectFolder")}{break}
{inp:iefolder new round baseline , projectfolder("$projectFolder")}

{pstd}In the example above, in the line the first time {cmd:iefolder} is used, a folder
	called {hi:DataWork} is created at the location of {it:"C:\Users\Documents\DropBox\ProjectABC"}.
	In the line where {cmd:iefolder} used a second time, a folder for the baseline round
	is created inside the {hi:DataWork} folder. Note that the folder provided
	in {inp:projectfolder()} is the same both times.

{pstd}Both the {hi:DataWork} folder and the {hi:baseline} folder created have sub-folders
	and master do-files creating globals pointing to these.

{pstd}{hi:Example 2.}

{pmore}{inp:global projectFolder "C:\Users\Documents\DropBox\ProjectABC"}

{pmore}{inp:iefolder new project , projectfolder("$projectFolder")}{break}
{inp:iefolder new round baseline , projectfolder("$projectFolder") abbreviation("BL")}

{pstd}The example above creates the same folder structure as in Example 1, but
	in the globals in the master do-files the abbreviation BL is used instead of
	baseline. But the folders created on disk will still be called baseline.

{pstd} {hi:Example 3.}

{pstd}The example below is meant to describe an intended workflow for a full
	life cycle of an impact evaluation. First we need to set up the {hi:DataWork} folder.
	We do that using {it:{cmd:iefolder} new project}. Like this:

{pmore}{inp:iefolder new project , projectfolder("C:\Users\Documents\DropBox\ProjectABC")}

{pstd}Our first data collection will be a baseline where the unit of observation
	is households. We therefore need to set up folders for the unit of observation
	"households". In the encrypted master folder for "housholds" you can create your
	list over households and you have a subfolder called {it:Sampling} where you
	can keep do files and data with identifying infomration. We create all of that by
	using {it:{cmd:iefolder} new untiofobs household}.	Like this:

{pmore}{inp:iefolder new untiofobs household , projectfolder("C:\Users\Documents\DropBox\ProjectABC") abbreviation("BL")}

{pstd}When we are ready to start preparing for the baseline we want to create the
	baseline folder. We do that using {it:{cmd:iefolder} new round baseline}. Like this:

{pmore}{inp:iefolder new round baseline , projectfolder("C:\Users\Documents\DropBox\ProjectABC") abbreviation("BL")}

{pstd}At this point we can collect the baseline data, save the data in the folders
	we created and write the report. Then long stretches of time might pass before
	we need to use the command.

{pstd}Let's say that when we plan for midline we also want
	to collect data about the villages that the households we interview in baseline
	live in. Then we need to create a new master folder for the unit of observation
	villages. We do that using {it:{cmd:iefolder} new untiofobs village}. Like this:

{pmore}{inp:iefolder new untiofobs village , projectfolder("$projectFolder")}

{pstd}Then we need to create the rounds used for the midline round for both
	households and for villages. Since this is separate data collection (although
	they might happen at the same time). We create those folders like this:

{pmore}{inp:iefolder new round midlineVillage , projectfolder("$projectFolder") abbreviation("ML")}{break}
{inp:iefolder new round midline {space 6}     , projectfolder("$projectFolder") abbreviation("MLvill")}

{pstd}Finally, in the last round of data collection, we are only collecting data
	on households again. Since we are not collecting data on any new unit
	of observation, we do not need to create any new master folder.

{pmore}{inp:iefolder new round endline , projectfolder("$projectFolder") abbreviation("EL")}

{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}Luiza Cardoso De Andrade{break}Laura Costica{break}Seungmin Lee{break}Mrijan Rimal{break}Sakina Shibuya

{title:Author}

{phang}Kristoffer Bjarkefur, The World Bank, DECIE

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

{title:Title}

{phang2}{cmdab:iefolder} {hline 2} sets up project folders and master do-files according to World Bank DIME's standards.

{title:Syntax}

{pstd} {ul:When initially setting up the {hi:DataWork} folder in a new project:}

{phang2}{cmd:iefolder} new project, {cmdab:proj:ectfolder(}{it:directory}{cmd:)}

{pstd} {ul:When adding folders to and already existing {hi:DataWork} folder:}

{phang2}{cmd:iefolder} new {it:itemtype} {it:itemname} , {cmdab:proj:ectfolder(}{it:directory}{cmd:)}
	[{cmdab:abb:reviation(}{it:string}{cmd:)}]

{pmore}where {it:itemtype} is either {it:round} or {it:unitofobs}. See
	details on {it:itemtype} and {it:itemname} below.

{marker opts}{...}
{synoptset 22}{...}
{synopthdr:options}
{synoptline}
{synopt : {cmdab:proj:ectfolder(}{it:dir}{cmd:)}}The location of
	the project folder where the {hi:DataWork} folder should be
	created (new projects), or where it is located (new round and new unitofobs).{p_end}
{synopt : {cmdab:abb:reviation(}{it:string}{cmd:)}}Optional abbreviation
	of round name to be used to make globals shorter. Can only be used
	when {it:itemtype} is round.{p_end}
{synoptline}

{marker desc}{title:Description}

{pstd}{cmdab:iefolder} automates the process of setting up the folder and master do-files
	where all the data work will take place in a project folder. The folders set
	up will follow DIME's best practices outlined and explained here:
	{browse "https://dimewiki.worldbank.org/wiki/DataWork_Folder"} (This page
	is a part of a Wiki that we are in the final stage of getting approval to
	release externally, the page is until then unfortunately password protected.)

{pstd}In addition to setting up the {hi:DataWork} folder and its sub-folders, the
	command creates master do-files linking to all of these sub-folders. These
	master do-files are updated whenever more subfolders are added using this command.

{pstd}{ul:{hi:itemtypes}}. This command can create either a new DataWork folder or add folders to an
	existing DataWork folder. The existing DataWork folder must have been created
	with {cmd:iefolder} for the additions to work. There are two types of folders
	that can be added to an existing folder, {ul:round} and {ul:untiofobs}. See
	next paragraphs for descriptions.

{pstd}{hi:{it:round}} folders are folders specific to a data collection round, for example, {it:Baseline}, {it:Endline},
	{it:Follow Up} etc. When adding a new round, sub-folders are added to the DataWork
	folder in line with the best practice described here:
	{browse "https://dimewiki.worldbank.org/wiki/DataWork_Survey_Round"}. {cmd:iefolder} also
	creates a master do-file specific for the round with globals references the sub-folders
	specific to this round. {cmd:iefolder} is implemented so that you can keep working
	for years with your project in between adding folders. The command reads the content
	of the folder and the project master do-file and make the addition in those files
	preserving the manual changes that has been done.

{pstd}{hi:{it:untiofobs}} folders are folders specific to a unit of observation,
	for example the master data set folder. Read more about master data sets and the folder structure
	this commands sets up for you at {browse "https://dimewiki.worldbank.org/wiki/Master_Data_Set"}. A
	master data folder for each new unit of observation is created in two places. Both in
	the MasterData folder in the DataWork folder, and in the MasterKeyID folder in the encrypted folder.

{marker optslong}{title:Options}

{phang}{cmdab:proj:ectfolder(}{it:dir}{cmd:)} should point to the same folder regardless
	of which {it:itemtype} is created. If {it:new project} is specified the file path should
	point to where DataWork should be created, and if {it:new round} or {it:new project} is
	specified, it should point to where DataWork was already created. See how the file path is
	the same both time when {cmd:iefolder} is called twice in Example 1.

{phang}{cmdab:abb:reviation(}{it:string}{cmd:)} can be used to shorten the globals created
	in the master do-files that point to the sub-folders to {it:round} folders. For example,
	if you create a new {it:round} called Baseline, as in Example 1, then a global to the
	DataSet folder called Baseline_dt will be created in the master do-file. If the
	abbreviation option would have been used, like in Example 2, then the global would
	have been called BL_dt.

{title:Examples}

{pstd}{hi:Example 1.}

{pmore}{inp:global projectFolder "C:\Users\Documents\DropBox\ProjectABC"}

{pmore}{inp:iefolder new project , projectfolder("$projectFolder")}{break}
{inp:iefolder new round baseline , projectfolder("$projectFolder")}

{pstd}In the example above, in the line the first time {cmd:iefolder} is used, a folder
	called {hi:DataWork} is created at the location of "C:\Users\Documents\DropBox\ProjectABC".
	In the line where {cmd:iefolder} used a second time, a folder for the baseline round
	is created inside the {hi:DataWork} folder. Note that the folder provided
	in {inp:projectfolder()} is the same both times.

{pstd}Both the {hi:DataWork} folder and the {hi:baseline} folder created have sub-folders
	and master do-files creating globals pointing to these.

{pstd}{hi:Example 2.}

{pmore}{inp:global projectFolder "C:\Users\Documents\DropBox\ProjectABC"}

{pmore}{inp:iefolder new project , projectfolder("$projectFolder")}{break}
{inp:iefolder new round baseline , projectfolder("$projectFolder") abbreviation("BL")}

{pstd}The example above creates the same folder structure as in Example 1, but
	in the globals in the master do-files the abbreviation BL is used instead of
	baseline. But the folders created on disk will still be called baseline.

{pstd} {hi:Example 3.}

{pstd}The example below is meant to describe an intended workflow for a full
	life cycle of an impact evaluation. First we need to set up the {hi:DataWork} folder.
	We do that using {it:{cmd:iefolder} new project}. Like this:

{pmore}{inp:iefolder new project , projectfolder("C:\Users\Documents\DropBox\ProjectABC")}

{pstd}Our first data collection will be a baseline where the unit of observation
	is households. We therefore need to set up folders for the unit of observation
	"households". In the encrypted master folder for "housholds" you can create your
	list over households and you have a subfolder called {it:Sampling} where you
	can keep do files and data with identifying infomration. We create all of that by
	using {it:{cmd:iefolder} new untiofobs household}.	Like this:

{pmore}{inp:iefolder new untiofobs household , projectfolder("C:\Users\Documents\DropBox\ProjectABC") abbreviation("BL")}

{pstd}When we are ready to start preparing for the baseline we want to create the
	baseline folder. We do that using {it:{cmd:iefolder} new round baseline}. Like this:

{pmore}{inp:iefolder new round baseline , projectfolder("C:\Users\Documents\DropBox\ProjectABC") abbreviation("BL")}

{pstd}At this point we can collect the baseline data, save the data in the folders
	we created and write the report. Then long stretches of time might pass before
	we need to use the command.

{pstd}Let's say that when we plan for midline we also want
	to collect data about the villages that the households we interview in baseline
	live in. Then we need to create a new master folder for the unit of observation
	villages. We do that using {it:{cmd:iefolder} new untiofobs village}. Like this:

{pmore}{inp:iefolder new untiofobs village , projectfolder("$projectFolder")}

{pstd}Then we need to create the rounds used for the midline round for both
	households and for villages. Since this is separate data collection (although
	they might happen at the same time). We create those folders like this:

{pmore}{inp:iefolder new round midlineVillage , projectfolder("$projectFolder") abbreviation("ML")}{break}
{inp:iefolder new round midline {space 6}     , projectfolder("$projectFolder") abbreviation("MLvill")}

{pstd}Finally, in the last round of data collection, we are only collecting data
	on households again. Since we are not collecting data on any new unit
	of observation, we do not need to create any new master folder.

{pmore}{inp:iefolder new round endline , projectfolder("$projectFolder") abbreviation("EL")}

{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}Laura Costica{break}Seungmin Lee{break}Mrijan Rimal{break}

{title:Author}

{phang}Kristoffer Bjarkefur, The World Bank, DECIE

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


iefolder : help first draft

iefolder : help first draft

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

{title:Title}

{phang2}{cmdab:iefolder} {hline 2} Sets up project folders and master do-files according to World Bank DIME's standards.

{title:Syntax}

{phang2}
{cmd:iefolder} new {it:itemtype} , {cmdab:proj:ectfolder(}{it:directory}{cmd:)}
	[{cmdab:abb:reviation(}{it:string}{cmd:)}]

{pmore}where {it:itemtype} is either {it:project}, {it:round} or {it:master}. See
	details on itemtypes below.

{marker opts}{...}
{synoptset 22}{...}
{synopthdr:options}
{synoptline}
{synopt :{it:new itemtype}}Specifies if you want to create a DataWork folder in a
	new {ul:{it:project}} or add a new {ul:{it:round}} folder or new {ul:{it:master}}
	folders.{p_end}
{synopt : {cmdab:proj:ectfolder(}{it:dir}{cmd:)}}The location of
	the project folder where the {hi:DataWork} folder should be
	created (new projects), or where it is located (existing projects).{p_end}
{synopt : {cmdab:abb:reviation(}{it:string}{cmd:)}}Optional abbreviation
	of round name to be used to make globals shorter. {p_end}
{synoptline}

{marker desc}{title:Description}

{pstd}{cmdab:iefolder} automizes the process of setting up the folder in a
	project folder where all the data work will take place. The folders set
	up will follow DIME's best practices outlined and explained here:
	{browse "https://dimewiki.worldbank.org/wiki/DataWork_Folder"} (This page
	is a part of a Wiki that we are in the final stage of getting approval to
	release externally, the page is until then unfortunatelly password protected.)

{pstd}In addition to setting up the {hi:DataWork} folder and it sub-folders the
	command creates master do-files linking to all of these sub-folders. These
	master do-files are updated whenever more subfolders are added using this command.

{pstd}{ul:{hi:itemtypes}}. This command can create either a new DataWork folder or add folders to an
	existing DataWork folder. The existing DataWork fodler must have been created
	with {cmd:iefolder} for the additions to work. There are two types of folders
	that can be added to an existing folder, {ul:{round} and {ul:{master}.
	See next paragraphs for descriptions.

{pstd}{ul:round} folders are folders specific to a data collection round, for example, {it:Baseline}, {it:Endline},
	{it:Follow Up} etc. When adding a new round, sub-folders are added to the DataWork
	folder in line with the best practice described here:
	{browse "https://dimewiki.worldbank.org/wiki/DataWork_Survey_Round"}. {cmd:iefolder} also
	creates a master do-file specific for the round with globals references the sub-folders
	specific to this round. {cmd:iefolder} is implemented so that you can keep working
	for years with your project inbetween adding folders. The command reads the content
	of the folder and the project master do-file and make the addition in accordance to
	that.

{pstd}{ul:master} folders are folders specific to the master data sets that corresponds
	to each unit of observation. Read more about master data sets and the folder structure
	this commands sets up for you at {browse "https://dimewiki.worldbank.org/wiki/Master_Data_Set"}. A
	master data folder for each new unit of observation is created in two places. Both in
	the MasterData folder in the DataWork folder, and in the MasterKeyID folder in the encrypted folder.

{marker optslong}{title:Options}

{phang}{it:new itemtype} is used to specify what to create when {cmd:iefolder} is used.
	There are three {it:itemtpyes} meaning that it can either be sepcified as {it:new project},
	{it:new round} or {it:new master}. {it:new project} sets up the initia

{phang}{cmdab:proj:ectfolder(}{it:dir}{cmd:)} should point to the same folder regardless
	of which {it:itemtype}is created. If {it:new project} is specified the file path should
	point to where DataWork should be created, and if {it:new round} or {it:new project} is
	specified, it should point to where DataWork was already created. See how the file path is
	the same both time when {cmd:iefolder} is called twice in Example 1.

{phang}{cmdab:abb:reviation(}{it:string}{cmd:)} can be used to shorten the globals created
	in the master do-files that point to the sub-folders to {it:roundf} folders. For example,
	if you create a new {it:round} called Baseline, as in Example 1, then a global to the
	DataSet folder called Baseline_dt will be created in the master do-file. If the
	abbrevation office would have been used like in Example 2, then the global would
	have been called BL_dt.

{title:Examples}

{pstd} {hi:Example 1.}

{pmore}{inp:global projectFolder "C:\Users\Documents\DropBox\ProjectABC"}

{pmore}{inp:iefolder new project , projectfolder("$projectFolder")}{break}
{inp:iefolder new round baseline , projectfolder("$projectFolder")}

{pmore}In the example above,

{pstd} {hi:Example 2.}

{pmore}{inp:global projectFolder "C:\Users\Documents\DropBox\ProjectABC"}

{pmore}{inp:iefolder new project , projectfolder("$projectFolder")}{break}
{inp:iefolder new round baseline , projectfolder("$projectFolder") , abbvreviation("BL")}

{pmore}In the example above,

{pstd} {hi:Example 2.}

{pmore}{inp:global projectFolder "C:\Users\Documents\DropBox\ProjectABC"}

{pmore}{inp:iefolder new project , projectfolder("$projectFolder")}{break}
{inp:iefolder new master household , projectfolder("$projectFolder") , abbvreviation("BL")}{break}
{inp:iefolder new round baseline , projectfolder("$projectFolder") , abbvreviation("BL")}

{pmore}{inp:iefolder new round midline , projectfolder("$projectFolder") , abbvreviation("ML")}{break}
{inp:iefolder new master village , projectfolder("$projectFolder")}

{pmore}{inp:iefolder new round endline , projectfolder("$projectFolder") , abbvreviation("EL")}

{pmore}In the example above,

{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}Laura Costica{break}Seungmin Lee{break}Mrijan Rimal{break}

{title:Author}

{phang}Kristoffer Bjarkefur, The World Bank, DECIE

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

{title:Title}

{phang2}{cmdab:iefolder} {hline 2} Sets up project folders and master do-files according to World Bank DIME's standards.

{title:Syntax}

{phang2}
{cmd:iefolder} new {it:itemtype} , {cmdab:proj:ectfolder(}{it:directory}{cmd:)}
	[{cmdab:abb:reviation(}{it:string}{cmd:)}]

{pmore} Where {it:itemtype} is either {it:project}, {it:round}, {it:master} or
	{it:unitofobs}. See details below.

{marker opts}{...}
{synoptset 22}{...}
{synopthdr:options}
{synoptline}
{synopt : {cmdab:proj:ectfolder(}{it:dir}{cmd:)}}The location where
	the {hi:DataWork} folder should be created (new projects), or
	where it is located (existing projects). {p_end}
{synopt : {cmdab:abb:reviation(}{it:string}{cmd:)}}Optional abbreviation
	of round name to be used to make globals shorter. {p_end}

{marker desc}
{title:Description}

{pstd}{cmdab:iefolder} automizes the process of setting up the folder in a
	project folder where all the data work will take place. The folders set
	up will follow DIME's best practices outlined and explained here:
	{browse "https://dimewiki.worldbank.org/wiki/DataWork_Folder"} (This page
	is a part of a Wiki that we are in the final stage of getting approval to
	release externally, the page is until then unfortunatelly password protected.)

{pstd}In addition to setting up the {hi:DataWork} folder and it sub-folders the
	command creates master do-files linking to all of these sub-folders. These
	master do-files are updated whenever more subfolders are added using this command.

{pstd}This command can create either a new DataWork folder or add folders to an
	existing DataWork folder. The existing DataWork fodler must have been created
	with {cmd:iefolder} for the additions to work. There are two types of folders
	that can be added to an existing folder, {ul:{hi:round}} and {ul:{hi:master}}.
	See next paragraphs for descriptions.

{pstd}{ul:{hi:round}} folders are folders specific to a data collection round, for example, {it:Baseline}, {it:Endline},
	{it:Follow Up} etc. When adding a new round, sub-folders are added to the DataWork
	folder in line with the best practice described here:
	{browse "https://dimewiki.worldbank.org/wiki/DataWork_Survey_Round"}. {cmd:iefolder} also
	creates a master do-file specific for the round with globals references the sub-folders
	specific to this round. {cmd:iefolder} is implemented so that you can keep working
	for years with your project inbetween adding folders. The command reads the content
	of the folder and the project master do-file and make the addition in accordance to
	that.

{pstd}{ul:{hi:master}} folder is folders specific to the master data sets that corresponds
	to each unit of observation. Read more about master data sets and the folder structure
	this commands sets up for you at {browse "https://dimewiki.worldbank.org/wiki/Master_Data_Set"}. A
	master data folder for each new unit of observation is created in two places. Both in
	the MasterData folder in the DataWork folder, and in the MasterKeyID folder in the encrypted folder.

{marker optslong}
{title:Options}

{phang}{cmdab:proj:ectfolder(}{it:dir}{cmd:)} is

{phang}{cmdab:abb:reviation(}{it:string}{cmd:)} is

{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, Seungmin Lee, Laura Costica{break}

{title:Author}

{phang}Kristoffer Bjarkefur, The World Bank, DECIE

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


add mean

add mean

program reg_all

local mode `1'
local ln `2'

make_data `mode'
run_reg `ln'bd
local meanline "\vspace{5mm} ($\mu$=$meanvar)\\"
esttab using "${tables}`mode'.tex", ${top} posthead("\midrule \underline{\textbf{Panel A: Citations}} `meanline'")

make_data `mode'
run_reg `ln'img
local meanline "\vspace{5mm} ($\mu$=$meanvar)\\"
esttab using "${tables}`mode'.tex",  ${middle} posthead("\midrule \vspace{5mm} \underline{\textbf{Panel B : Images}}`meanline'")

make_data `mode'
run_reg `ln'text
local meanline "\vspace{5mm} ($\mu$=$meanvar)\\"
esttab using "${tables}`mode'.tex",   ${end} posthead("\midrule \vspace{5mm} \underline{\textbf{Panel C : Text}}`meanline'")

end

program save_mean

local var `1'
qui tabstat `var', save
matrix stats=r(StatTotal)
global meanvar=round(stats[1,1],0.01)
global meanvar : di %3.2f $meanvar

di "jsut saved $meanvar"

end

program make_data

local mode `1'

use ${stash}master, clear
fvset base 2013 year

if "`mode'" == "digit" {
    gen tvar = isbaseball
}

if "`mode'" == "copy" {
    drop if isbaseball == 0
    gen tvar = treat
}

end

program run_reg

est clear
local x `1'

save_mean `x'

eststo: qui xtreg `x' 1.tvar#1.post, fe cluster(id)

qui estadd local fixed "Yes"
qui estadd local yearfe "No"
qui estadd local mean "${meanvar}"

eststo: qui xtreg `x' 1.tvar#1.post i.${fe}, fe cluster(id)
qui estadd local fixed "Yes"
qui estadd local yearfe "Yes"
qui estadd local mean "${meanvar}"

keep if year==2008 | year==2013

eststo: qui xtreg `x' 1.tvar#1.post i.${fe}, fe cluster(id)
qui estadd local fixed "Yes"
qui estadd local yearfe "Yes"
qui estadd local mean "${meanvar}"

end

program reg_all

local mode `1'
local ln `2'

make_data `mode'
run_reg `ln'bd
esttab using "${tables}`mode'.tex", ${top} posthead("\midrule \vspace{5mm} \underline{\textbf{Panel A: Citations }}\\")

make_data `mode'
run_reg `ln'img
esttab using "${tables}`mode'.tex",  ${middle} posthead("\midrule \vspace{5mm} \underline{\textbf{Panel B : Images}}\\")

make_data `mode'
run_reg `ln'text
esttab using "${tables}`mode'.tex",   ${end} posthead("\midrule \vspace{5mm} \underline{\textbf{Panel C : Text}}\\")

end

program save_mean

local var `1'
qui tabstat `var', save
matrix stats=r(StatTotal)
global meanvar=round(stats[1,1],0.01)

end

program make_data

local mode `1'

use ${stash}master, clear
fvset base 2013 year

if "`mode'" == "digit" {
    gen tvar = isbaseball
}

if "`mode'" == "copy" {
    drop if isbaseball == 0
    gen tvar = treat
}

end

program run_reg

est clear
local x `1'

eststo: qui xtreg `x' 1.tvar#1.post, fe cluster(id)

save_mean `x'
qui estadd local fixed "Yes"
qui estadd local yearfe "No"
qui estadd local mean "${meanvar}"

eststo: qui xtreg `x' 1.tvar#1.post i.${fe}, fe cluster(id)
qui estadd local fixed "Yes"
qui estadd local yearfe "Yes"
qui estadd local mean "${meanvar}"

keep if year==2008 | year==2013

eststo: qui xtreg `x' 1.tvar#1.post i.${fe}, fe cluster(id)
save_mean `x'
qui estadd local fixed "Yes"
qui estadd local yearfe "Yes"
qui estadd local mean "${meanvar}"

end


Added pstars and filewrite

Added pstars and filewrite

Filewrite added

cap	program drop	ieimpgraph
	program define 	ieimpgraph

	syntax varlist

	mat beta_ = e(b)

	local counter = 0
	local textfile = "Mrijan"
	local date = "$S_DATE"

	qui{

	foreach var of local varlist{
		cap assert inlist(`var',0,1) | missing(`var')
			if _rc {
				noi display as error "{phang} The variable `var' is not a dummy. Treatment variable needs to be a dummy(0 or 1) variable. {p_end}"
				noi display ""
				error 149
				}
			else {
				}

		local counter = `counter' + 1
		di `counter'

		scalar coeff_`var' = _b[`var']
		noi display coeff_`var'

		scalar coeff_se_`var' = _se[`var']
		noi display coeff_se_`var'

		count if e(sample) == 1 & `var' == 1 //Count one tmt group at the time
		scalar obs_`var' = r(N)
		noi display obs_`var'

	}

	local count: word count `varlist'
	tokenize "`varlist'"
	noi di `count'

	//Make all vars tempvars (maybe do later)
	//Make sure that missing is properly handled
	tempvar anyTMT
	egen `anyTMT' = rowmax(`varlist') if e(sample) == 1
	tempvar control
	gen `control' = (`anyTMT' == 0) if !missing(`anyTMT')

	noi sum `e(depvar)' if e(sample) == 1 & `control' == 1
	scalar ctl_N		= r(N)
	scalar ctl_mean	  	= r(mean)
	scalar ctl_mean_sd 	= r(sd)

		foreach var of local varlist {
			scalar  conf_int_min_`var'   =	coeff_`var'-(1.96*coeff_se_`var') + ctl_mean
			scalar  conf_int_max_`var'   =	coeff_`var'+(1.96*coeff_se_`var') + ctl_mean

			noi test `var'
			local star_`var'

			scalar  pvalue =r(p)
			if pvalue < 0.10 {
				local star_`var' "*"
			}
			if pvalue < 0.05 {
				local star_`var' "**"
			}
			if pvalue < 0.01 {
				local star_`var' "***"
			}
			noi display "`star_`var''"
			scalar tmt_mean_`var' = ctl_mean + coeff_`var'
		}

	tempname 	newHandle
	tempfile	newTextFile
	cap file close 	`newHandle'
	file open  	`newHandle' using "`newTextFile'", text write append
	file write `newHandle' ///
		"Variable" 	_tab "Tmt-Status"	_tab "mean" _tab "coeff" _tab "conf_int_min" _tab "conf_int_max" _tab "obs" _tab "star" _n
	file close `newHandle'
	copy "`newTextFile'"  "mainMasterDofile.txt" , replace
}
end

cap	program drop	ieimpgraph
	program define 	ieimpgraph

	syntax varlist

	mat beta_ = e(b)

	local counter = 0
	local textfile = "Mrijan"
	local date = "$S_DATE"
qui{

foreach var of local varlist{

		//Test that var is dummy (i.e. 0 or 1 or missing)

		local counter = `counter' + 1
		di `counter'

		scalar beta_`var' = _b[`var']
		noi display beta_`var'

		scalar coeff_se_`var' = _se[`var']
		noi display coeff_se_`var'

		count if e(sample) == 1 & `var' == 1 //Count one tmt group at the time
		scalar obs_`var' = r(N)
		noi display obs_`var'

	}
local count: word count `varlist'
tokenize "`varlist'"
noi di `count'

//Make all vars tempvars (maybe do later)
//Make sure that missing is properly handled
gen anyTMT = rowmax(`varlist') if e(sample) == 1
gen control = (anyTmt == 0) if !missing(anyTMT)

noi sum `e(depvar)' if e(sample) == 1 & control == 1
scalar ctl_N		= r(N)
scalar ctl_mean	  	= r(mean)
scalar ctl_mean_sd 	= r(sd)

}
end


(minor) input display

(minor) input display

// -------------------------------------------------------------
// Display Regression Table
// -------------------------------------------------------------
cap pr drop Replay
 program define Replay, eclass
	syntax , [*]
	Assert e(cmd)=="reghdfe"
	local subcmd = e(subcmd)
	Assert "`subcmd'"!="" , msg("e(subcmd) is empty")
	if (`c(version)'>=12) local hidden hidden

	local savefirst = e(savefirst)

	local diopts = "`e(diopts)'"
	if ("`options'"!="") { // Override
		_get_diopts diopts /* options */, `options'
	}

	if ("`subcmd'"=="ivregress") {
		* Don't want to display anova table or footnote
		_coef_table_header
		_coef_table, `diopts' bmatrix(`b') vmatrix(e(V)) // plus
	}
	else if ("`subcmd'"=="ivreg2") {
		* Backup before showing both first and second stage
		tempname hold

		if ("`e(firsteqs)'"!="") {
			estimates store `hold'

			local i 0
			foreach fs_eqn in `e(firsteqs)' {
				local instrument  : word `++i' of `e(instd)'
				di _n "{input}{title:First stage for `instrument'}"
				cap noi estimates replay `fs_eqn' , nohead `diopts'
				if (!`savefirst') estimates drop `fs_eqn'
			}

			ereturn clear
			qui estimates restore `hold'
			di _n "{input}{title:Second stage}"
		}

		// BUGBUG: Update this part
		estimates store `hold'
		// ereturn repost b=`b', rename
		ereturn local cmd = "`subcmd'"
		`subcmd' , `diopts'
		ereturn clear // Need this because -estimates restore- behaves oddly
		qui estimates restore `hold'
		assert e(cmd)=="reghdfe"
		estimates drop `hold'

		*ereturn local cmd = "reghdfe"
		*matrix `b' = e(b)
		*matrix colnames `b' = `backup_colnames'
		*ereturn repost b=`b', rename
	}
	else {

		* Regress-specific code, because it doesn't play nice with ereturn
		sreturn clear

		if "`e(prefix)'" != "" {
			_prefix_display, `diopts'
			exit
		}

		*_coef_table_header
		Header

		di
		local plus = cond(e(model)=="ols" & inlist("`e(vce)'", "unadjusted", "ols"), "plus", "")
		_coef_table, `plus' `diopts' bmatrix(`b') vmatrix(e(V))
	}
	mata: reghdfe_width = max(strlen(st_matrixcolstripe_split("r(table)", 32, 0)))
	mata: st_local("width" , strofreal(reghdfe_width))
	mata: mata drop reghdfe_width
	if (`width'<12) local width 12
	ereturn `hidden' scalar width = `width'
	reghdfe_footnote
end

// -------------------------------------------------------------
// Display Regression Table
// -------------------------------------------------------------
cap pr drop Replay
 program define Replay, eclass
	syntax , [*]
	Assert e(cmd)=="reghdfe"
	local subcmd = e(subcmd)
	Assert "`subcmd'"!="" , msg("e(subcmd) is empty")
	if (`c(version)'>=12) local hidden hidden

	local savefirst = e(savefirst)

	local diopts = "`e(diopts)'"
	if ("`options'"!="") { // Override
		_get_diopts diopts /* options */, `options'
	}

	if ("`subcmd'"=="ivregress") {
		* Don't want to display anova table or footnote
		_coef_table_header
		_coef_table, `diopts' bmatrix(`b') vmatrix(e(V)) // plus
	}
	else if ("`subcmd'"=="ivreg2") {
		* Backup before showing both first and second stage
		tempname hold

		if ("`e(firsteqs)'"!="") {
			estimates store `hold'

			local i 0
			foreach fs_eqn in `e(firsteqs)' {
				local instrument  : word `++i' of `e(instd)'
				di _n "{input}{title:First stage for `instrument'}"
				cap noi estimates replay `fs_eqn' , nohead `diopts'
				if (!`savefirst') estimates drop `fs_eqn'
			}

			ereturn clear
			qui estimates restore `hold'
			di as input _n "{title:Second stage}"
		}

		// BUGBUG: Update this part
		estimates store `hold'
		// ereturn repost b=`b', rename
		ereturn local cmd = "`subcmd'"
		`subcmd' , `diopts'
		ereturn clear // Need this because -estimates restore- behaves oddly
		qui estimates restore `hold'
		assert e(cmd)=="reghdfe"
		estimates drop `hold'

		*ereturn local cmd = "reghdfe"
		*matrix `b' = e(b)
		*matrix colnames `b' = `backup_colnames'
		*ereturn repost b=`b', rename
	}
	else {

		* Regress-specific code, because it doesn't play nice with ereturn
		sreturn clear

		if "`e(prefix)'" != "" {
			_prefix_display, `diopts'
			exit
		}

		*_coef_table_header
		Header

		di
		local plus = cond(e(model)=="ols" & inlist("`e(vce)'", "unadjusted", "ols"), "plus", "")
		_coef_table, `plus' `diopts' bmatrix(`b') vmatrix(e(V))
	}
	mata: reghdfe_width = max(strlen(st_matrixcolstripe_split("r(table)", 32, 0)))
	mata: st_local("width" , strofreal(reghdfe_width))
	mata: mata drop reghdfe_width
	if (`width'<12) local width 12
	ereturn `hidden' scalar width = `width'
	reghdfe_footnote
end