one more mata file modified that goes with mlib

*! version 1.16.4.20 20abr2016
* Generates the corresponding dofiles

/**oxygen
 * @brief Writes a fully functional do-file to be runned by -parallel_run()-.
 * @param inputname Name of a do-file or string with a commando to be runned.
 * @param parallelid Parallel instance ID.
 * @param ncluster Number of clusters (files).
 * @param prefix Whether this is a command (prefix != 0) or a do-file.
 * @param matsave Whether to include or not MATA objects.
 * @param getmacros Whete to include or not Globals.
 * @param seed Seed to be used (list)
 * @param randtype If no seeds provided, type of algorithm used to generate the seeds
 * @param nodata Wheter to load (1) data or not.
 * @param folder Folder where the do-file should be running.
 * @param programs A list of programs to be used within each cluster.
 * @param processors Number of statamp processors to use in each cluster.
 * @returns As many do-files as clusers used.
 */
mata:

real scalar parallel_temp_sequence(string scalar id_part){
	real rowvector ascii_codes, nice_ind
	real scalar num, i, exp
	ascii_codes = ascii(id_part)
	nice_ind = ascii_codes :- ((ascii_codes :> 57):*7:+48) /*zero-based and reindexed (letters smashed down to numbers)*/
	num = 1
	for(i=length(nice_ind); i>=1; i--){
		exp = length(nice_ind)-i
		num = num+nice_ind[i]*(36^exp)
	}
	return(num)
}

real scalar parallel_write_do(
	string scalar inputname,
	string scalar parallelid,
	| real scalar nclusters,
	real   scalar prefix,
	real   scalar matasave,
	real   scalar getmacros,
	string scalar seed,
	string scalar randtype,
	real   scalar nodata,
	string scalar folder,
	string scalar programs,
	real scalar processors,
	real scalar work_around_no_cwd,
	string scalar output_opts
	)
{
	real vector input_fh, output_fh
	string scalar line, fname, nexttempname
	string scalar memset, maxvarset, matsizeset
	real scalar i, n_prev_tempnames
	string colvector seeds
	string scalar new_lib, output_opts_final
	string rowvector output_opts_toks

	// Checking optargs
	if (matasave == J(1,1,.)) matasave = 0
	if (prefix == J(1,1,.)) prefix = 1
	if (getmacros == J(1,1,.)) getmacros = 0
	if (nclusters == J(1,1,.)) {
		if (strlen(st_global("PLL_CLUSTERS"))) nclusters = strtoreal(st_global("PLL_CLUSTERS"))
		else {
			errprintf("You haven't set the number of clusters\nPlease set it with -{cmd:parallel setclusters} {it:#}-}\n")
			return(198)
		}
	}

	/* Check seeds and seeds length */
	if (seed == J(1,1,""))
	{
		seeds = parallel_randomid(5, randtype, 0, nclusters, 1)
		st_local("pllseeds", invtokens(seeds'))
	}
	else
	{
		st_local("pllseeds", seed)
		seeds = tokens(seed)
		/* Checking seeds length */
		if (length(seeds) > nclusters)
		{
			errprintf("Seeds provided -%g- doesn't match seeds needed -%g-\n", length(seeds), nclusters)
			return(123)
		}
		else if (length(seeds) < nclusters)
		{
			errprintf("Seeds provided -%g- doesn't match seeds needed -%g-\n", length(seeds), nclusters)
			return(122)
		}
	}
	if (nodata == J(1,1,.)) nodata = 0
	if (folder == J(1,1,"")) folder = c("pwd")

	real scalar progsave
	if (programs !="") progsave = 1
	else progsave = 0

	/* Checks for the MP version */
	if (!c("MP") & processors != 0 & processors != J(1,1,.)) display("{result:Warning:}{text: processors option ignored...}")
	else if (processors == J(1,1,.) | processors == 0) processors = 1

	if (work_around_no_cwd == J(1,1,.))  work_around_no_cwd=0

	real scalar err
	err = 0
	if (progsave)  err = parallel_export_programs(folder+"__pll"+parallelid+"_prog.do", programs, folder+"__pll"+parallelid+"_prog.log")
	if (getmacros) parallel_export_globals(folder+"__pll"+parallelid+"_glob.do")

	if (err)
	{
		errprintf("An error has occurred while exporting -programs-")
		return(err)
	}

	//figure out the tempname state
	nexttempname=st_tempname()
	n_prev_tempnames = parallel_temp_sequence(substr(nexttempname,3))-1

	for(i=1;i<=nclusters;i++)
	{
		// Sets dofile
                fname = folder+"__pll"+parallelid+"_do"+strofreal(i,"%04.0f")+".do"
		if (fileexists(fname)) unlink(fname)
		output_fh = fopen(fname, "w", 1)

		// Step 1
		fput(output_fh, "capture {")
		fput(output_fh, "clear")
		if (c("MP")) fput(output_fh, "set processors "+strofreal(processors))
		fput(output_fh, `"cd ""'+folder+`"""')

		//Copy over the adopath & matalibs order
		//PERSONAL & PLUS are the most likely to be overwritten and referenced in S_ADO. (could do others)
		fput(output_fh, `"sysdir set PERSONAL ""' + st_global("c(sysdir_personal)") +`"""')
		fput(output_fh, `"sysdir set PLUS ""' + st_global("c(sysdir_plus)") +`"""')
		if(work_around_no_cwd==0){
			fput(output_fh, "global S_ADO = `"+`"""'+st_global("S_ADO")+`"""'+"'")
		}
		else{
			fput(output_fh, "global S_ADO = `"+`"""'+st_global("S_ADO")+`";.""'+"'")
		}
		fput(output_fh, "mata: mata mlib index")
		new_lib = (length(st_global("c(matalibs)"))>0 ? ";" : "")+"l__pll"+parallelid+"_mlib"
		//   c(matalibs) will outputted at the time parallel is called (not when child process is called)
		// so the final order will be the original+new_lib. The 'mlib index' command above ensures we can
		// find the new lib. And this next line is needed because if 'keep' is used with previous -parallel-
		// calls then we don't want to include all the other temporary libraries.
		fput(output_fh, `"mata: mata set matalibs ""'+st_global("c(matalibs)")+new_lib+`"""')

		fput(output_fh, "set seed "+seeds[i])

		if (st_global("PLL_INCLUDE_FILE")!=""){
			fput(output_fh, `"include ""'+st_global("PLL_INCLUDE_FILE")+`"""')
		}

		/* Parallel macros to be used by the current user */
		fput(output_fh, `"noi di "{hline 80}""')
		fput(output_fh, `"noi di "Parallel computing with Stata""')
		fput(output_fh, `"noi di "{hline 80}""')
		fput(output_fh, sprintf(`"noi di \`"cmd/dofile   : "%s""'"', inputname))
		fput(output_fh, sprintf(`"noi di "pll_id       : %s""',parallelid))
		fput(output_fh, sprintf(`"noi di "pll_instance : %g/%g""',i,nclusters))
		fput(output_fh,         `"noi di "tmpdir       : \`c(tmpdir)'""')
		fput(output_fh,         `"noi di "date-time    : \`c(current_time)' \`c(current_date)'""')
		fput(output_fh,         `"noi di "seed         : \`c(seed)'""')
		fput(output_fh, `"noi di "{hline 80}""')
		fput(output_fh, "local pll_instance "+strofreal(i))
		fput(output_fh, "local pll_id "+parallelid)
		fput(output_fh, "global pll_instance "+strofreal(i))
		fput(output_fh, "global pll_id "+parallelid)

		// Data requirements
		if (!nodata)
		{
			if (c("MP") | c("SE"))
			{
				// Building data limits
				memset     = sprintf("%9.0f",c("memory")/nclusters)
				maxvarset  = sprintf("%g",c("maxvar"))
				matsizeset = sprintf("%g",c("matsize"))

				// Writing data limits
				if (!c("MP")) fput(output_fh, "set memory "+memset+"b")
				fput(output_fh, "set maxvar "+maxvarset)
				fput(output_fh, "set matsize "+matsizeset)
			}
		}

		if (n_prev_tempnames>0) fput(output_fh, `"mata: for(i=1;i<="'+strofreal(n_prev_tempnames)+`";i++) PLL_QUIET = st_tempname()"')

		/* Checking data setting is just fine */
		fput(output_fh, "}")
		fput(output_fh, "local result = _rc")
		fput(output_fh, "if (c(rc)) {")
		fput(output_fh, `"cd ""'+folder+`"""')
		fput(output_fh, `"mata: parallel_write_diagnosis(strofreal(c("rc")),""'+folder+"__pll"+parallelid+"_finito"+strofreal(i,"%04.0f")+`"","while setting memory")"')
		fput(output_fh, "clear")
		fput(output_fh, "exit")
		fput(output_fh, "}")

		// Loading programs
		if (progsave)
		{
			fput(output_fh, sprintf("\n* Loading Programs *"))
			fput(output_fh, "capture {")
			fput(output_fh, `"run ""'+folder+"__pll"+parallelid+`"_prog.do""')
			/* Checking programs loading is just fine */
			fput(output_fh, "}")
			fput(output_fh, "local result = _rc")
			fput(output_fh, "if (c(rc)) {")
			fput(output_fh, `"cd ""'+folder+`"""')
			fput(output_fh, `"mata: parallel_write_diagnosis(strofreal(c("rc")),""'+folder+"__pll"+parallelid+"_finito"+strofreal(i,"%04.0f")+`"","while loading programs")"')
			fput(output_fh, "clear")
			fput(output_fh, "exit")
			fput(output_fh, "}")
		}

		/* Checking for break key
		fput(output_fh, sprintf("\n* Checking for break *"))
		fput(output_fh, "mata: parallel_break()") */

		// Mata objects loading
		if (matasave)
		{
			fput(output_fh, sprintf("\n* Loading Mata Objects *"))
			fput(output_fh, "capture {")
			fput(output_fh, `"mata: mata matuse ""'+folder+"__pll"+parallelid+`"_mata.mmat""')
			/* Checking programs loading is just fine */
			fput(output_fh, "}")
			fput(output_fh, "local result = _rc")
			fput(output_fh, "if (c(rc)) {")
			fput(output_fh, `"cd ""'+folder+`"""')
			fput(output_fh, `"mata: parallel_write_diagnosis(strofreal(c("rc")),""'+folder+"__pll"+parallelid+"_finito"+strofreal(i,"%04.0f")+`"","while loading mata objects")"')
			fput(output_fh, "clear")
			fput(output_fh, "exit")
			fput(output_fh, "}")
		}

		/* Checking for break key */
		fput(output_fh, sprintf("\n* Checking for break *"))
		fput(output_fh, "mata: parallel_break()")

		// Globals loading
		if (getmacros)
		{
			fput(output_fh, sprintf("\n* Loading Globals *"))
			fput(output_fh, "capture {")
			fput(output_fh, `"cap run ""'+folder+"__pll"+parallelid+`"_glob.do""')
			/* Checking programs loading is just fine */
			fput(output_fh, "}")
			fput(output_fh, "if (c(rc)) {")
			fput(output_fh, `"  cd ""'+folder+`"""')
			fput(output_fh, `"  mata: parallel_write_diagnosis(strofreal(c("rc")),""'+folder+"__pll"+parallelid+"_finito"+strofreal(i,"%04.0f")+`"","while loading globals")"')
			fput(output_fh, "  clear")
			fput(output_fh, "  exit")
			fput(output_fh, "}")
		}

		/* Checking for break key */
		fput(output_fh, sprintf("\n* Checking for break *"))
		fput(output_fh, "mata: parallel_break()")

		// Step 2
		fput(output_fh, "capture {")
		fput(output_fh, "  noisily {")

		// If it is not a command, i.e. a dofile
		if (!nodata){
			fput(output_fh, `"    use ""'+folder+"__pll"+parallelid+`"_dataset" if _"'+parallelid+"cut == "+strofreal(i))
			fput(output_fh, "    drop _"+parallelid+"cut")
		}

		/* Checking for break key */
		fput(output_fh, sprintf("\n* Checking for break *"))
		fput(output_fh, "mata: parallel_break()")

		if (!prefix) {
			input_fh = fopen(inputname, "r", 1)

			while ((line=fget(input_fh))!=J(0,0,"")) fput(output_fh, "    "+line)
			fclose(input_fh)
		} // if it is a command
		else{
			//convert potential output_opts
			output_opts_toks = tokens(output_opts)
			output_opts_toks = output_opts_toks :+ "(" :+ folder :+ "__pll" :+ parallelid :+ "_out_" :+ output_opts_toks :+ strofreal(i,"%04.0f") :+ ")"
			output_opts_final = invtokens(output_opts_toks, " ")

			fput(output_fh, "    "+inputname+" "+output_opts_final)
		}

		fput(output_fh, "  }")
		fput(output_fh, "}")

		/* Checking programs loading is just fine */
		fput(output_fh, "if (c(rc)) {")
		fput(output_fh, `"  cd ""'+folder+`"""')
		fput(output_fh, `"  mata: parallel_write_diagnosis(strofreal(c("rc")),""'+folder+"__pll"+parallelid+"_finito"+strofreal(i,"%04.0f")+`"","while running the command/dofile")"')
		fput(output_fh, "  clear")
		fput(output_fh, "  exit")
		fput(output_fh, "}")

		fput(output_fh, `"mata: parallel_write_diagnosis(strofreal(c("rc")),""'+folder+"__pll"+parallelid+"_finito"+strofreal(i,"%04.0f")+`"","while executing the command")"')

		if (!nodata) fput(output_fh, `"save ""'+folder+"__pll"+parallelid+"_dta"+strofreal(i,"%04.0f")+`"", replace"')

		// Step 3
		fput(output_fh, `"cd ""'+folder+`"""')
		fclose(output_fh)
	}
	return(0)
}
end

*! version 1.16.4.20 20abr2016
* Generates the corresponding dofiles

/**oxygen
 * @brief Writes a fully functional do-file to be runned by -parallel_run()-.
 * @param inputname Name of a do-file or string with a commando to be runned.
 * @param parallelid Parallel instance ID.
 * @param ncluster Number of clusters (files).
 * @param prefix Whether this is a command (prefix != 0) or a do-file.
 * @param matsave Whether to include or not MATA objects.
 * @param getmacros Whete to include or not Globals.
 * @param seed Seed to be used (list)
 * @param randtype If no seeds provided, type of algorithm used to generate the seeds
 * @param nodata Wheter to load (1) data or not.
 * @param folder Folder where the do-file should be running.
 * @param programs A list of programs to be used within each cluster.
 * @param processors Number of statamp processors to use in each cluster.
 * @returns As many do-files as clusers used.
 */
mata:

real scalar parallel_temp_sequence(string scalar id_part){
	real rowvector ascii_codes, nice_ind
	real scalar num, i, exp
	ascii_codes = ascii(id_part)
	nice_ind = ascii_codes :- ((ascii_codes :> 57):*7:+48) /*zero-based and reindexed (letters smashed down to numbers)*/
	num = 1
	for(i=length(nice_ind); i>=1; i--){
		exp = length(nice_ind)-i
		num = num+nice_ind[i]*(36^exp)
	}
	return(num)
}

real scalar parallel_write_do(
	string scalar inputname,
	string scalar parallelid,
	| real scalar nclusters,
	real   scalar prefix,
	real   scalar matasave,
	real   scalar getmacros,
	string scalar seed,
	string scalar randtype,
	real   scalar nodata,
	string scalar folder,
	string scalar programs,
	real scalar processors,
	real scalar work_around_no_cwd,
	string scalar output_opts
	)
{
	real vector input_fh, output_fh
	string scalar line, fname, nexttempname
	string scalar memset, maxvarset, matsizeset
	real scalar i, n_prev_tempnames
	string colvector seeds
	string scalar new_lib, output_args, output_opts_final
	string rowvector output_opts_toks

	// Checking optargs
	if (matasave == J(1,1,.)) matasave = 0
	if (prefix == J(1,1,.)) prefix = 1
	if (getmacros == J(1,1,.)) getmacros = 0
	if (nclusters == J(1,1,.)) {
		if (strlen(st_global("PLL_CLUSTERS"))) nclusters = strtoreal(st_global("PLL_CLUSTERS"))
		else {
			errprintf("You haven't set the number of clusters\nPlease set it with -{cmd:parallel setclusters} {it:#}-}\n")
			return(198)
		}
	}

	/* Check seeds and seeds length */
	if (seed == J(1,1,""))
	{
		seeds = parallel_randomid(5, randtype, 0, nclusters, 1)
		st_local("pllseeds", invtokens(seeds'))
	}
	else
	{
		st_local("pllseeds", seed)
		seeds = tokens(seed)
		/* Checking seeds length */
		if (length(seeds) > nclusters)
		{
			errprintf("Seeds provided -%g- doesn't match seeds needed -%g-\n", length(seeds), nclusters)
			return(123)
		}
		else if (length(seeds) < nclusters)
		{
			errprintf("Seeds provided -%g- doesn't match seeds needed -%g-\n", length(seeds), nclusters)
			return(122)
		}
	}
	if (nodata == J(1,1,.)) nodata = 0
	if (folder == J(1,1,"")) folder = c("pwd")

	real scalar progsave
	if (programs !="") progsave = 1
	else progsave = 0

	/* Checks for the MP version */
	if (!c("MP") & processors != 0 & processors != J(1,1,.)) display("{result:Warning:}{text: processors option ignored...}")
	else if (processors == J(1,1,.) | processors == 0) processors = 1

	if (work_around_no_cwd == J(1,1,.))  work_around_no_cwd=0

	real scalar err
	err = 0
	if (progsave)  err = parallel_export_programs(folder+"__pll"+parallelid+"_prog.do", programs, folder+"__pll"+parallelid+"_prog.log")
	if (getmacros) parallel_export_globals(folder+"__pll"+parallelid+"_glob.do")

	if (err)
	{
		errprintf("An error has occurred while exporting -programs-")
		return(err)
	}

	//figure out the tempname state
	nexttempname=st_tempname()
	n_prev_tempnames = parallel_temp_sequence(substr(nexttempname,3))-1

	for(i=1;i<=nclusters;i++)
	{
		// Sets dofile
                fname = folder+"__pll"+parallelid+"_do"+strofreal(i,"%04.0f")+".do"
		if (fileexists(fname)) unlink(fname)
		output_fh = fopen(fname, "w", 1)

		// Step 1
		fput(output_fh, "capture {")
		fput(output_fh, "clear")
		if (c("MP")) fput(output_fh, "set processors "+strofreal(processors))
		fput(output_fh, `"cd ""'+folder+`"""')

		//Copy over the adopath & matalibs order
		//PERSONAL & PLUS are the most likely to be overwritten and referenced in S_ADO. (could do others)
		fput(output_fh, `"sysdir set PERSONAL ""' + st_global("c(sysdir_personal)") +`"""')
		fput(output_fh, `"sysdir set PLUS ""' + st_global("c(sysdir_plus)") +`"""')
		if(work_around_no_cwd==0){
			fput(output_fh, "global S_ADO = `"+`"""'+st_global("S_ADO")+`"""'+"'")
		}
		else{
			fput(output_fh, "global S_ADO = `"+`"""'+st_global("S_ADO")+`";.""'+"'")
		}
		fput(output_fh, "mata: mata mlib index")
		new_lib = (length(st_global("c(matalibs)"))>0 ? ";" : "")+"l__pll"+parallelid+"_mlib"
		//   c(matalibs) will outputted at the time parallel is called (not when child process is called)
		// so the final order will be the original+new_lib. The 'mlib index' command above ensures we can
		// find the new lib. And this next line is needed because if 'keep' is used with previous -parallel-
		// calls then we don't want to include all the other temporary libraries.
		fput(output_fh, `"mata: mata set matalibs ""'+st_global("c(matalibs)")+new_lib+`"""')

		fput(output_fh, "set seed "+seeds[i])

		if (st_global("PLL_INCLUDE_FILE")!=""){
			fput(output_fh, `"include ""'+st_global("PLL_INCLUDE_FILE")+`"""')
		}

		/* Parallel macros to be used by the current user */
		fput(output_fh, `"noi di "{hline 80}""')
		fput(output_fh, `"noi di "Parallel computing with Stata""')
		fput(output_fh, `"noi di "{hline 80}""')
		fput(output_fh, sprintf(`"noi di \`"cmd/dofile   : "%s""'"', inputname))
		fput(output_fh, sprintf(`"noi di "pll_id       : %s""',parallelid))
		fput(output_fh, sprintf(`"noi di "pll_instance : %g/%g""',i,nclusters))
		fput(output_fh,         `"noi di "tmpdir       : \`c(tmpdir)'""')
		fput(output_fh,         `"noi di "date-time    : \`c(current_time)' \`c(current_date)'""')
		fput(output_fh,         `"noi di "seed         : \`c(seed)'""')
		fput(output_fh, `"noi di "{hline 80}""')
		fput(output_fh, "local pll_instance "+strofreal(i))
		fput(output_fh, "local pll_id "+parallelid)
		fput(output_fh, "global pll_instance "+strofreal(i))
		fput(output_fh, "global pll_id "+parallelid)

		// Data requirements
		if (!nodata)
		{
			if (c("MP") | c("SE"))
			{
				// Building data limits
				memset     = sprintf("%9.0f",c("memory")/nclusters)
				maxvarset  = sprintf("%g",c("maxvar"))
				matsizeset = sprintf("%g",c("matsize"))

				// Writing data limits
				if (!c("MP")) fput(output_fh, "set memory "+memset+"b")
				fput(output_fh, "set maxvar "+maxvarset)
				fput(output_fh, "set matsize "+matsizeset)
			}
		}

		if (n_prev_tempnames>0) fput(output_fh, `"mata: for(i=1;i<="'+strofreal(n_prev_tempnames)+`";i++) PLL_QUIET = st_tempname()"')

		/* Checking data setting is just fine */
		fput(output_fh, "}")
		fput(output_fh, "local result = _rc")
		fput(output_fh, "if (c(rc)) {")
		fput(output_fh, `"cd ""'+folder+`"""')
		fput(output_fh, `"mata: parallel_write_diagnosis(strofreal(c("rc")),""'+folder+"__pll"+parallelid+"_finito"+strofreal(i,"%04.0f")+`"","while setting memory")"')
		fput(output_fh, "clear")
		fput(output_fh, "exit")
		fput(output_fh, "}")

		// Loading programs
		if (progsave)
		{
			fput(output_fh, sprintf("\n* Loading Programs *"))
			fput(output_fh, "capture {")
			fput(output_fh, `"run ""'+folder+"__pll"+parallelid+`"_prog.do""')
			/* Checking programs loading is just fine */
			fput(output_fh, "}")
			fput(output_fh, "local result = _rc")
			fput(output_fh, "if (c(rc)) {")
			fput(output_fh, `"cd ""'+folder+`"""')
			fput(output_fh, `"mata: parallel_write_diagnosis(strofreal(c("rc")),""'+folder+"__pll"+parallelid+"_finito"+strofreal(i,"%04.0f")+`"","while loading programs")"')
			fput(output_fh, "clear")
			fput(output_fh, "exit")
			fput(output_fh, "}")
		}

		/* Checking for break key
		fput(output_fh, sprintf("\n* Checking for break *"))
		fput(output_fh, "mata: parallel_break()") */

		// Mata objects loading
		if (matasave)
		{
			fput(output_fh, sprintf("\n* Loading Mata Objects *"))
			fput(output_fh, "capture {")
			fput(output_fh, `"mata: mata matuse ""'+folder+"__pll"+parallelid+`"_mata.mmat""')
			/* Checking programs loading is just fine */
			fput(output_fh, "}")
			fput(output_fh, "local result = _rc")
			fput(output_fh, "if (c(rc)) {")
			fput(output_fh, `"cd ""'+folder+`"""')
			fput(output_fh, `"mata: parallel_write_diagnosis(strofreal(c("rc")),""'+folder+"__pll"+parallelid+"_finito"+strofreal(i,"%04.0f")+`"","while loading mata objects")"')
			fput(output_fh, "clear")
			fput(output_fh, "exit")
			fput(output_fh, "}")
		}

		/* Checking for break key */
		fput(output_fh, sprintf("\n* Checking for break *"))
		fput(output_fh, "mata: parallel_break()")

		// Globals loading
		if (getmacros)
		{
			fput(output_fh, sprintf("\n* Loading Globals *"))
			fput(output_fh, "capture {")
			fput(output_fh, `"cap run ""'+folder+"__pll"+parallelid+`"_glob.do""')
			/* Checking programs loading is just fine */
			fput(output_fh, "}")
			fput(output_fh, "if (c(rc)) {")
			fput(output_fh, `"  cd ""'+folder+`"""')
			fput(output_fh, `"  mata: parallel_write_diagnosis(strofreal(c("rc")),""'+folder+"__pll"+parallelid+"_finito"+strofreal(i,"%04.0f")+`"","while loading globals")"')
			fput(output_fh, "  clear")
			fput(output_fh, "  exit")
			fput(output_fh, "}")
		}

		/* Checking for break key */
		fput(output_fh, sprintf("\n* Checking for break *"))
		fput(output_fh, "mata: parallel_break()")

		// Step 2
		fput(output_fh, "capture {")
		fput(output_fh, "  noisily {")

		// If it is not a command, i.e. a dofile
		if (!nodata){
			fput(output_fh, `"    use ""'+folder+"__pll"+parallelid+`"_dataset" if _"'+parallelid+"cut == "+strofreal(i))
			fput(output_fh, "    drop _"+parallelid+"cut")
		}

		/* Checking for break key */
		fput(output_fh, sprintf("\n* Checking for break *"))
		fput(output_fh, "mata: parallel_break()")

		if (!prefix) {
			input_fh = fopen(inputname, "r", 1)

			while ((line=fget(input_fh))!=J(0,0,"")) fput(output_fh, "    "+line)
			fclose(input_fh)
		} // if it is a command
		else{
			//convert potential output_opts
			output_opts_toks = tokens(output_opts)
			output_opts_toks = output_opts_toks :+ "(" :+ folder :+ "__pll" :+ parallelid :+ "_out_" :+ output_opts_toks :+ strofreal(i,"%04.0f") :+ ")"
			output_opts_final = invtokens(output_opts_toks, " ")

			fput(output_fh, "    "+inputname+" "+output_opts_final)
		}

		fput(output_fh, "  }")
		fput(output_fh, "}")

		/* Checking programs loading is just fine */
		fput(output_fh, "if (c(rc)) {")
		fput(output_fh, `"  cd ""'+folder+`"""')
		fput(output_fh, `"  mata: parallel_write_diagnosis(strofreal(c("rc")),""'+folder+"__pll"+parallelid+"_finito"+strofreal(i,"%04.0f")+`"","while running the command/dofile")"')
		fput(output_fh, "  clear")
		fput(output_fh, "  exit")
		fput(output_fh, "}")

		fput(output_fh, `"mata: parallel_write_diagnosis(strofreal(c("rc")),""'+folder+"__pll"+parallelid+"_finito"+strofreal(i,"%04.0f")+`"","while executing the command")"')

		if (!nodata) fput(output_fh, `"save ""'+folder+"__pll"+parallelid+"_dta"+strofreal(i,"%04.0f")+`"", replace"')

		// Step 3
		fput(output_fh, `"cd ""'+folder+`"""')
		fclose(output_fh)
	}
	return(0)
}
end


Added DRAM signals to wave.do file

Added DRAM signals to wave.do file

onerror {resume}
quietly WaveActivateNextPane {} 0
add wave -noupdate -expand -group {clk and reset} -radix hexadecimal /top_tb/T1/clk
add wave -noupdate -expand -group {clk and reset} -radix hexadecimal /top_tb/T1/reset
add wave -noupdate -group FETCH -radix hexadecimal /top_tb/T1/stall_fetch
add wave -noupdate -group FETCH -radix hexadecimal /top_tb/T1/instr_pc_reg_fetch
add wave -noupdate -group FETCH -radix hexadecimal /top_tb/T1/curr_pc_pc_reg_fetch
add wave -noupdate -group FETCH -radix hexadecimal /top_tb/T1/next_pc_fetch_iss
add wave -noupdate -group FETCH -radix hexadecimal /top_tb/T1/next_seq_pc_pc_reg_fetch
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/valid_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/stall_iss
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/next_seq_pc_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/next_brn_eq_pc_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/next_jmp_pc_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/is_i_type_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/is_j_type_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/is_r_type_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/instr_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/op_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/funct_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/shamt_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/target_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/reg_src_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/reg_dst_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/jump_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/branch_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/mem_read_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/mem_to_reg_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal -childformat {{{/top_tb/T1/alu_op_iss_ex[5]} -radix hexadecimal} {{/top_tb/T1/alu_op_iss_ex[4]} -radix hexadecimal} {{/top_tb/T1/alu_op_iss_ex[3]} -radix hexadecimal} {{/top_tb/T1/alu_op_iss_ex[2]} -radix hexadecimal} {{/top_tb/T1/alu_op_iss_ex[1]} -radix hexadecimal} {{/top_tb/T1/alu_op_iss_ex[0]} -radix hexadecimal}} -subitemconfig {{/top_tb/T1/alu_op_iss_ex[5]} {-height 16 -radix hexadecimal} {/top_tb/T1/alu_op_iss_ex[4]} {-height 16 -radix hexadecimal} {/top_tb/T1/alu_op_iss_ex[3]} {-height 16 -radix hexadecimal} {/top_tb/T1/alu_op_iss_ex[2]} {-height 16 -radix hexadecimal} {/top_tb/T1/alu_op_iss_ex[1]} {-height 16 -radix hexadecimal} {/top_tb/T1/alu_op_iss_ex[0]} {-height 16 -radix hexadecimal}} /top_tb/T1/alu_op_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/mem_wr_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal -childformat {{{/top_tb/T1/alu_src_iss_ex[2]} -radix hexadecimal} {{/top_tb/T1/alu_src_iss_ex[1]} -radix hexadecimal} {{/top_tb/T1/alu_src_iss_ex[0]} -radix hexadecimal}} -subitemconfig {{/top_tb/T1/alu_src_iss_ex[2]} {-height 16 -radix hexadecimal} {/top_tb/T1/alu_src_iss_ex[1]} {-height 16 -radix hexadecimal} {/top_tb/T1/alu_src_iss_ex[0]} {-height 16 -radix hexadecimal}} /top_tb/T1/alu_src_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/reg_wr_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/sign_ext_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/sign_imm_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/sign_ext_iss
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/rd_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/rs_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/rt_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/r_data_p1_rf_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/r_data_p2_rf_iss_ex
add wave -noupdate -group EXECUTE -radix hexadecimal /top_tb/T1/valid_ex_mem
add wave -noupdate -group EXECUTE -radix hexadecimal /top_tb/T1/flush_ex
add wave -noupdate -group EXECUTE -radix hexadecimal /top_tb/T1/branch_ex_mem
add wave -noupdate -group EXECUTE -radix hexadecimal /top_tb/T1/branch_taken_ex_mem
add wave -noupdate -group EXECUTE -radix hexadecimal /top_tb/T1/next_brn_eq_pc_ex_mem
add wave -noupdate -group EXECUTE -radix hexadecimal /top_tb/T1/alu_op_ex_mem
add wave -noupdate -group EXECUTE -radix hexadecimal /top_tb/T1/alu_src_ex_mem
add wave -noupdate -group EXECUTE -radix hexadecimal /top_tb/T1/reg_dst_ex_mem
add wave -noupdate -group EXECUTE -radix hexadecimal /top_tb/T1/mem_to_reg_ex_mem
add wave -noupdate -group EXECUTE -radix hexadecimal /top_tb/T1/mem_wr_ex_mem
add wave -noupdate -group EXECUTE -radix hexadecimal /top_tb/T1/reg_wr_ex_mem
add wave -noupdate -group EXECUTE -radix hexadecimal /top_tb/T1/sign_imm_ex_mem
add wave -noupdate -group EXECUTE -radix hexadecimal /top_tb/T1/rd_ex_mem
add wave -noupdate -group EXECUTE -radix hexadecimal /top_tb/T1/rs_ex_mem
add wave -noupdate -group EXECUTE -radix hexadecimal /top_tb/T1/rt_ex_mem
add wave -noupdate -group EXECUTE -radix hexadecimal /top_tb/T1/r_data_p1_alu_ex_mem
add wave -noupdate -group EXECUTE -radix hexadecimal /top_tb/T1/r_data_p1_rf_ex_mem
add wave -noupdate -group EXECUTE -radix hexadecimal /top_tb/T1/r_data_p2_alu_ex_mem
add wave -noupdate -group EXECUTE -radix hexadecimal /top_tb/T1/r_data_p2_rf_ex_mem
add wave -noupdate -group EXECUTE -radix hexadecimal /top_tb/T1/fwd_r_data_p1_alu_ex
add wave -noupdate -group EXECUTE -radix hexadecimal /top_tb/T1/fwd_r_data_p2_alu_ex
add wave -noupdate -group EXECUTE -radix hexadecimal /top_tb/T1/res_alu_ex_mem
add wave -noupdate -group EXECUTE -radix hexadecimal /top_tb/T1/n_ex_mem
add wave -noupdate -group EXECUTE -radix hexadecimal /top_tb/T1/z_ex_mem
add wave -noupdate -group MEMORY -radix hexadecimal /top_tb/T1/valid_mem_wb
add wave -noupdate -group MEMORY -radix hexadecimal /top_tb/T1/mem_to_reg_mem_wb
add wave -noupdate -group MEMORY -radix hexadecimal /top_tb/T1/mem_wr_mem_wb
add wave -noupdate -group MEMORY -radix hexadecimal /top_tb/T1/reg_wr_mem_wb
add wave -noupdate -group MEMORY -radix hexadecimal /top_tb/T1/rd_mem_wb
add wave -noupdate -group MEMORY -radix hexadecimal /top_tb/T1/res_alu_mem_wb
add wave -noupdate -group MEMORY -radix hexadecimal /top_tb/T1/read_data_dmem_ram_mem_wb
add wave -noupdate -group WRITE-BACK -radix hexadecimal /top_tb/T1/valid_wb_ret
add wave -noupdate -group WRITE-BACK -radix hexadecimal /top_tb/T1/mem_to_reg_wb_ret
add wave -noupdate -group WRITE-BACK -radix hexadecimal /top_tb/T1/reg_wr_wb_ret
add wave -noupdate -group WRITE-BACK -radix hexadecimal /top_tb/T1/rd_wb_ret
add wave -noupdate -group WRITE-BACK -radix hexadecimal /top_tb/T1/res_alu_wb_ret
add wave -noupdate -group WRITE-BACK -radix hexadecimal /top_tb/T1/read_data_wb_ret
add wave -noupdate -group WRITE-BACK -radix hexadecimal /top_tb/T1/wr_data_rf_wb_ret
add wave -noupdate -group RF -radix hexadecimal /top_tb/T1/R1/clk
add wave -noupdate -group RF -radix hexadecimal /top_tb/T1/R1/r_data_p1
add wave -noupdate -group RF -radix hexadecimal /top_tb/T1/R1/r_data_p1_rf_o
add wave -noupdate -group RF -radix hexadecimal /top_tb/T1/R1/r_data_p2
add wave -noupdate -group RF -radix hexadecimal /top_tb/T1/R1/r_data_p2_rf_o
add wave -noupdate -group RF -radix hexadecimal /top_tb/T1/R1/r_reg_p1_rf_i
add wave -noupdate -group RF -radix hexadecimal /top_tb/T1/R1/r_reg_p2_rf_i
add wave -noupdate -group RF -radix hexadecimal -childformat {{{/top_tb/T1/R1/reg_file[31]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[30]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[29]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[28]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[27]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[26]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[25]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[24]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[23]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[22]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[21]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[20]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[19]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[18]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[17]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[16]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[15]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[14]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[13]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[12]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[11]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[10]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[9]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[8]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[7]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[6]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[5]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[4]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[3]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[2]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[1]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[0]} -radix hexadecimal}} -subitemconfig {{/top_tb/T1/R1/reg_file[31]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[30]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[29]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[28]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[27]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[26]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[25]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[24]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[23]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[22]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[21]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[20]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[19]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[18]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[17]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[16]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[15]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[14]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[13]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[12]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[11]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[10]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[9]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[8]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[7]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[6]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[5]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[4]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[3]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[2]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[1]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[0]} {-height 16 -radix hexadecimal}} /top_tb/T1/R1/reg_file
add wave -noupdate -group RF -radix hexadecimal /top_tb/T1/R1/reset
add wave -noupdate -group RF -radix hexadecimal /top_tb/T1/R1/w_data_rf_i
add wave -noupdate -group RF -radix hexadecimal /top_tb/T1/R1/w_en_rf_i
add wave -noupdate -group RF -radix hexadecimal /top_tb/T1/R1/w_reg_rf_i
add wave -noupdate -group ALU -radix hexadecimal /top_tb/T1/A1/opr_a_alu_i
add wave -noupdate -group ALU -radix hexadecimal /top_tb/T1/A1/opr_b_alu_i
add wave -noupdate -group ALU -radix hexadecimal /top_tb/T1/A1/op_alu_i
add wave -noupdate -group ALU -radix hexadecimal /top_tb/T1/A1/res_alu_o
add wave -noupdate -group ALU -radix hexadecimal /top_tb/T1/A1/n_alu_o
add wave -noupdate -group ALU -radix hexadecimal /top_tb/T1/A1/z_alu_o
add wave -noupdate -group HAZARD -radix hexadecimal /top_tb/T1/hazard/fwd_p1_ex_mem_hz_o
add wave -noupdate -group HAZARD -radix hexadecimal /top_tb/T1/hazard/fwd_p2_ex_mem_hz_o
add wave -noupdate -group HAZARD /top_tb/T1/flush_iss
add wave -noupdate -group HAZARD -radix hexadecimal /top_tb/T1/hazard/flush_ex_hz_o
add wave -noupdate -group HAZARD -radix hexadecimal /top_tb/T1/hazard/stall_fetch_hz_o
add wave -noupdate -group HAZARD -radix hexadecimal /top_tb/T1/hazard/stall_iss_hz_o
add wave -noupdate -group DRAM -radix hexadecimal /top_tb/T1/D_MEM1/addr_dmem_ram_i
add wave -noupdate -group DRAM -radix hexadecimal /top_tb/T1/D_MEM1/wr_en_dmem_ram_i
add wave -noupdate -group DRAM -radix hexadecimal /top_tb/T1/D_MEM1/wr_strb_dmem_ram_i
add wave -noupdate -group DRAM -radix hexadecimal /top_tb/T1/D_MEM1/wr_data_dmem_ram_i
add wave -noupdate -group DRAM -radix hexadecimal /top_tb/T1/D_MEM1/read_data_dmem_ram_o
TreeUpdate [SetDefaultTree]
WaveRestoreCursors {{Cursor 1} {10780 ps} 0}
quietly wave cursor active 1
configure wave -namecolwidth 325
configure wave -valuecolwidth 243
configure wave -justifyvalue left
configure wave -signalnamewidth 0
configure wave -snapdistance 10
configure wave -datasetprefix 0
configure wave -rowmargin 4
configure wave -childrowmargin 2
configure wave -gridoffset 0
configure wave -gridperiod 1
configure wave -griddelta 40
configure wave -timeline 0
configure wave -timelineunits ns
update
WaveRestoreZoom {10407 ps} {10996 ps}

onerror {resume}
quietly WaveActivateNextPane {} 0
add wave -noupdate -expand -group {clk and reset} -radix hexadecimal /top_tb/T1/clk
add wave -noupdate -expand -group {clk and reset} -radix hexadecimal /top_tb/T1/reset
add wave -noupdate -group FETCH -radix hexadecimal /top_tb/T1/stall_fetch
add wave -noupdate -group FETCH -radix hexadecimal /top_tb/T1/instr_pc_reg_fetch
add wave -noupdate -group FETCH -radix hexadecimal /top_tb/T1/curr_pc_pc_reg_fetch
add wave -noupdate -group FETCH -radix hexadecimal /top_tb/T1/next_pc_fetch_iss
add wave -noupdate -group FETCH -radix hexadecimal /top_tb/T1/next_seq_pc_pc_reg_fetch
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/valid_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/stall_iss
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/next_seq_pc_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/next_brn_eq_pc_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/next_jmp_pc_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/is_i_type_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/is_j_type_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/is_r_type_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/instr_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/op_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/funct_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/shamt_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/target_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/reg_src_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/reg_dst_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/jump_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/branch_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/mem_read_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/mem_to_reg_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal -childformat {{{/top_tb/T1/alu_op_iss_ex[5]} -radix hexadecimal} {{/top_tb/T1/alu_op_iss_ex[4]} -radix hexadecimal} {{/top_tb/T1/alu_op_iss_ex[3]} -radix hexadecimal} {{/top_tb/T1/alu_op_iss_ex[2]} -radix hexadecimal} {{/top_tb/T1/alu_op_iss_ex[1]} -radix hexadecimal} {{/top_tb/T1/alu_op_iss_ex[0]} -radix hexadecimal}} -subitemconfig {{/top_tb/T1/alu_op_iss_ex[5]} {-height 16 -radix hexadecimal} {/top_tb/T1/alu_op_iss_ex[4]} {-height 16 -radix hexadecimal} {/top_tb/T1/alu_op_iss_ex[3]} {-height 16 -radix hexadecimal} {/top_tb/T1/alu_op_iss_ex[2]} {-height 16 -radix hexadecimal} {/top_tb/T1/alu_op_iss_ex[1]} {-height 16 -radix hexadecimal} {/top_tb/T1/alu_op_iss_ex[0]} {-height 16 -radix hexadecimal}} /top_tb/T1/alu_op_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/mem_wr_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal -childformat {{{/top_tb/T1/alu_src_iss_ex[2]} -radix hexadecimal} {{/top_tb/T1/alu_src_iss_ex[1]} -radix hexadecimal} {{/top_tb/T1/alu_src_iss_ex[0]} -radix hexadecimal}} -subitemconfig {{/top_tb/T1/alu_src_iss_ex[2]} {-height 16 -radix hexadecimal} {/top_tb/T1/alu_src_iss_ex[1]} {-height 16 -radix hexadecimal} {/top_tb/T1/alu_src_iss_ex[0]} {-height 16 -radix hexadecimal}} /top_tb/T1/alu_src_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/reg_wr_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/sign_ext_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/sign_imm_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/sign_ext_iss
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/rd_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/rs_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/rt_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/r_data_p1_rf_iss_ex
add wave -noupdate -group ISSUE -radix hexadecimal /top_tb/T1/r_data_p2_rf_iss_ex
add wave -noupdate -group EXECUTE -radix hexadecimal /top_tb/T1/valid_ex_mem
add wave -noupdate -group EXECUTE -radix hexadecimal /top_tb/T1/flush_ex
add wave -noupdate -group EXECUTE -radix hexadecimal /top_tb/T1/branch_ex_mem
add wave -noupdate -group EXECUTE -radix hexadecimal /top_tb/T1/branch_taken_ex_mem
add wave -noupdate -group EXECUTE -radix hexadecimal /top_tb/T1/next_brn_eq_pc_ex_mem
add wave -noupdate -group EXECUTE -radix hexadecimal /top_tb/T1/alu_op_ex_mem
add wave -noupdate -group EXECUTE -radix hexadecimal /top_tb/T1/alu_src_ex_mem
add wave -noupdate -group EXECUTE -radix hexadecimal /top_tb/T1/reg_dst_ex_mem
add wave -noupdate -group EXECUTE -radix hexadecimal /top_tb/T1/mem_to_reg_ex_mem
add wave -noupdate -group EXECUTE -radix hexadecimal /top_tb/T1/mem_wr_ex_mem
add wave -noupdate -group EXECUTE -radix hexadecimal /top_tb/T1/reg_wr_ex_mem
add wave -noupdate -group EXECUTE -radix hexadecimal /top_tb/T1/sign_imm_ex_mem
add wave -noupdate -group EXECUTE -radix hexadecimal /top_tb/T1/rd_ex_mem
add wave -noupdate -group EXECUTE -radix hexadecimal /top_tb/T1/rs_ex_mem
add wave -noupdate -group EXECUTE -radix hexadecimal /top_tb/T1/rt_ex_mem
add wave -noupdate -group EXECUTE -radix hexadecimal /top_tb/T1/r_data_p1_alu_ex_mem
add wave -noupdate -group EXECUTE -radix hexadecimal /top_tb/T1/r_data_p1_rf_ex_mem
add wave -noupdate -group EXECUTE -radix hexadecimal /top_tb/T1/r_data_p2_alu_ex_mem
add wave -noupdate -group EXECUTE -radix hexadecimal /top_tb/T1/r_data_p2_rf_ex_mem
add wave -noupdate -group EXECUTE -radix hexadecimal /top_tb/T1/fwd_r_data_p1_alu_ex
add wave -noupdate -group EXECUTE -radix hexadecimal /top_tb/T1/fwd_r_data_p2_alu_ex
add wave -noupdate -group EXECUTE -radix hexadecimal /top_tb/T1/res_alu_ex_mem
add wave -noupdate -group EXECUTE -radix hexadecimal /top_tb/T1/n_ex_mem
add wave -noupdate -group EXECUTE -radix hexadecimal /top_tb/T1/z_ex_mem
add wave -noupdate -group MEMORY -radix hexadecimal /top_tb/T1/valid_mem_wb
add wave -noupdate -group MEMORY -radix hexadecimal /top_tb/T1/mem_to_reg_mem_wb
add wave -noupdate -group MEMORY -radix hexadecimal /top_tb/T1/mem_wr_mem_wb
add wave -noupdate -group MEMORY -radix hexadecimal /top_tb/T1/reg_wr_mem_wb
add wave -noupdate -group MEMORY -radix hexadecimal /top_tb/T1/rd_mem_wb
add wave -noupdate -group MEMORY -radix hexadecimal /top_tb/T1/res_alu_mem_wb
add wave -noupdate -group MEMORY -radix hexadecimal /top_tb/T1/read_data_dmem_ram_mem_wb
add wave -noupdate -group WRITE-BACK -radix hexadecimal /top_tb/T1/valid_wb_ret
add wave -noupdate -group WRITE-BACK -radix hexadecimal /top_tb/T1/mem_to_reg_wb_ret
add wave -noupdate -group WRITE-BACK -radix hexadecimal /top_tb/T1/reg_wr_wb_ret
add wave -noupdate -group WRITE-BACK -radix hexadecimal /top_tb/T1/rd_wb_ret
add wave -noupdate -group WRITE-BACK -radix hexadecimal /top_tb/T1/res_alu_wb_ret
add wave -noupdate -group WRITE-BACK -radix hexadecimal /top_tb/T1/read_data_wb_ret
add wave -noupdate -group WRITE-BACK -radix hexadecimal /top_tb/T1/wr_data_rf_wb_ret
add wave -noupdate -group RF -radix hexadecimal /top_tb/T1/R1/clk
add wave -noupdate -group RF -radix hexadecimal /top_tb/T1/R1/r_data_p1
add wave -noupdate -group RF -radix hexadecimal /top_tb/T1/R1/r_data_p1_rf_o
add wave -noupdate -group RF -radix hexadecimal /top_tb/T1/R1/r_data_p2
add wave -noupdate -group RF -radix hexadecimal /top_tb/T1/R1/r_data_p2_rf_o
add wave -noupdate -group RF -radix hexadecimal /top_tb/T1/R1/r_reg_p1_rf_i
add wave -noupdate -group RF -radix hexadecimal /top_tb/T1/R1/r_reg_p2_rf_i
add wave -noupdate -group RF -radix hexadecimal -childformat {{{/top_tb/T1/R1/reg_file[31]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[30]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[29]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[28]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[27]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[26]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[25]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[24]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[23]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[22]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[21]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[20]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[19]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[18]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[17]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[16]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[15]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[14]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[13]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[12]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[11]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[10]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[9]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[8]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[7]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[6]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[5]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[4]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[3]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[2]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[1]} -radix hexadecimal} {{/top_tb/T1/R1/reg_file[0]} -radix hexadecimal}} -subitemconfig {{/top_tb/T1/R1/reg_file[31]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[30]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[29]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[28]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[27]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[26]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[25]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[24]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[23]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[22]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[21]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[20]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[19]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[18]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[17]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[16]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[15]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[14]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[13]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[12]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[11]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[10]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[9]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[8]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[7]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[6]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[5]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[4]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[3]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[2]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[1]} {-height 16 -radix hexadecimal} {/top_tb/T1/R1/reg_file[0]} {-height 16 -radix hexadecimal}} /top_tb/T1/R1/reg_file
add wave -noupdate -group RF -radix hexadecimal /top_tb/T1/R1/reset
add wave -noupdate -group RF -radix hexadecimal /top_tb/T1/R1/w_data_rf_i
add wave -noupdate -group RF -radix hexadecimal /top_tb/T1/R1/w_en_rf_i
add wave -noupdate -group RF -radix hexadecimal /top_tb/T1/R1/w_reg_rf_i
add wave -noupdate -group ALU -radix hexadecimal /top_tb/T1/A1/opr_a_alu_i
add wave -noupdate -group ALU -radix hexadecimal /top_tb/T1/A1/opr_b_alu_i
add wave -noupdate -group ALU -radix hexadecimal /top_tb/T1/A1/op_alu_i
add wave -noupdate -group ALU -radix hexadecimal /top_tb/T1/A1/res_alu_o
add wave -noupdate -group ALU -radix hexadecimal /top_tb/T1/A1/n_alu_o
add wave -noupdate -group ALU -radix hexadecimal /top_tb/T1/A1/z_alu_o
add wave -noupdate -group HAZARD -radix hexadecimal /top_tb/T1/hazard/fwd_p1_ex_mem_hz_o
add wave -noupdate -group HAZARD -radix hexadecimal /top_tb/T1/hazard/fwd_p2_ex_mem_hz_o
add wave -noupdate -group HAZARD /top_tb/T1/flush_iss
add wave -noupdate -group HAZARD -radix hexadecimal /top_tb/T1/hazard/flush_ex_hz_o
add wave -noupdate -group HAZARD -radix hexadecimal /top_tb/T1/hazard/stall_fetch_hz_o
add wave -noupdate -group HAZARD -radix hexadecimal /top_tb/T1/hazard/stall_iss_hz_o
TreeUpdate [SetDefaultTree]
WaveRestoreCursors {{Cursor 1} {380 ps} 0}
quietly wave cursor active 1
configure wave -namecolwidth 325
configure wave -valuecolwidth 243
configure wave -justifyvalue left
configure wave -signalnamewidth 0
configure wave -snapdistance 10
configure wave -datasetprefix 0
configure wave -rowmargin 4
configure wave -childrowmargin 2
configure wave -gridoffset 0
configure wave -gridperiod 1
configure wave -griddelta 40
configure wave -timeline 0
configure wave -timelineunits ns
update
WaveRestoreZoom {156 ps} {476 ps}


update predict varlabel (d and xbd)

update predict varlabel (d and xbd)

program define reghdfe_p, rclass
	* Note: we IGNORE typlist and generate the newvar as double
	* Note: e(resid) is missing outside of e(sample), so we don't need to condition on e(sample)

	* HACK: Intersect -score- and replace with -residuals-
	cap syntax anything [if] [in], SCore
	loc was_score = !c(rc)
	if (`was_score') {
		* Call _score_spec to get newvarname; discard type
		* - This resolves wildcards that -margins- sends to predict (e.g. var* -> var1)
		* - Do we really need to pass it `if' and `in' ?
		_score_spec `anything', score
		loc 0 `s(varlist)' `if' `in' , residuals
	}

	syntax newvarname [if] [in] [, XB STDP Residuals D XBD DResiduals]

	* Ensure there is only one option
	opts_exclusive "`xb' `stdp' `residuals' `d' `xbd' `dresiduals'"

	* Default option is xb
	cap opts_exclusive "`xb' `stdp' `residuals' `d' `xbd' `dresiduals' placeholder"
	if (!c(rc)) {
		di as text "(option xb assumed; fitted values)"
		loc xb "xb"
	}

	local fixed_effects "`e(absvars)'"

	* Except for xb and stdp, we need the previously computed residuals
	if ("`xb'" == "" & "`stdp'" == "") {
		_assert ("`e(resid)'" != ""), msg("you must add the {bf:resid} option to reghdfe before running this prediction")
		conf numeric var `e(resid)', exact
	}

	if ("`xb'" != "" | "`stdp'" != "") {
		* xb: normal treatment
		PredictXB `varlist' `if' `in', `xb' `stdp'
	}
	else if ("`residuals'" != "") {
		* resid: just return the preexisting variable
		gen double `varlist' = `e(resid)' `if' `in'
		la var `varlist' "Residuals"
		if (`was_score') return local scorevars `varlist'
	}
	else if ("`d'" != "") {
		* d: y - xb - resid
		tempvar xb
		PredictXB `xb' `if' `in', xb
		gen double `varlist' = `e(depvar)' -  `xb' - `e(resid)' `if' `in'
		la var `varlist' "d[`fixed_effects']"
	}
	else if ("`xbd'" != "") {
		* xbd: y - resid
		gen double `varlist' = `e(depvar)' - `e(resid)' `if' `in'
		la var `varlist' "Xb + d[`fixed_effects']"
	}
	else if ("`dresiduals'" != "") {
		* dresid:	y - xb
		tempvar xb
		PredictXB `xb' `if' `in', xb
		gen double `varlist' = `e(depvar)' -  `xb' `if' `in'
	}
	else {
		error 100
	}
end

program PredictXB
	syntax newvarname [if] [in], [*]
	cap matrix list e(b) // if there are no regressors, _predict fails
	if (c(rc)) {
		gen double `varlist' = 0 `if' `in'
	}
	else {
		_predict double `varlist' `if' `in', `options'
	}
end

program define reghdfe_p, rclass
	* Note: we IGNORE typlist and generate the newvar as double
	* Note: e(resid) is missing outside of e(sample), so we don't need to condition on e(sample)

	* HACK: Intersect -score- and replace with -residuals-
	cap syntax anything [if] [in], SCore
	loc was_score = !c(rc)
	if (`was_score') {
		* Call _score_spec to get newvarname; discard type
		* - This resolves wildcards that -margins- sends to predict (e.g. var* -> var1)
		* - Do we really need to pass it `if' and `in' ?
		_score_spec `anything', score
		loc 0 `s(varlist)' `if' `in' , residuals
	}

	syntax newvarname [if] [in] [, XB STDP Residuals D XBD DResiduals]

	* Ensure there is only one option
	opts_exclusive "`xb' `stdp' `residuals' `d' `xbd' `dresiduals'"

	* Default option is xb
	cap opts_exclusive "`xb' `stdp' `residuals' `d' `xbd' `dresiduals' placeholder"
	if (!c(rc)) {
		di as text "(option xb assumed; fitted values)"
		loc xb "xb"
	}

	* Except for xb and stdp, we need the previously computed residuals
	if ("`xb'" == "" & "`stdp'" == "") {
		_assert ("`e(resid)'" != ""), msg("you must add the {bf:resid} option to reghdfe before running this prediction")
		conf numeric var `e(resid)', exact
	}

	if ("`xb'" != "" | "`stdp'" != "") {
		* xb: normal treatment
		PredictXB `varlist' `if' `in', `xb' `stdp'
	}
	else if ("`residuals'" != "") {
		* resid: just return the preexisting variable
		gen double `varlist' = `e(resid)' `if' `in'
		la var `varlist' "Residuals"
		if (`was_score') return local scorevars `varlist'
	}
	else if ("`d'" != "") {
		* d: y - xb - resid
		tempvar xb
		PredictXB `xb' `if' `in', xb
		gen double `varlist' = `e(depvar)' -  `xb' - `e(resid)' `if' `in'
	}
	else if ("`xbd'" != "") {
		* xbd: y - resid
		gen double `varlist' = `e(depvar)' - `e(resid)' `if' `in'
	}
	else if ("`dresiduals'" != "") {
		* dresid:	y - xb
		tempvar xb
		PredictXB `xb' `if' `in', xb
		gen double `varlist' = `e(depvar)' -  `xb' `if' `in'
	}
	else {
		error 100
	}
end

program PredictXB
	syntax newvarname [if] [in], [*]
	cap matrix list e(b) // if there are no regressors, _predict fails
	if (c(rc)) {
		gen double `varlist' = 0 `if' `in'
	}
	else {
		_predict double `varlist' `if' `in', `options'
	}
end


Fix t/130-mode: "ls -l" output is not always as expected

[tweaked by apenwarr to remove dependency on non-portable /usr/bin/stat]

umask 0022
redo mode1
MODE=$(python -c 'import os; print oct(os.stat("mode1").st_mode & 07777)')
[ "$MODE" = "0644" ] || exit 78

umask 0022
redo mode1
MODE="$(ls -l mode1 | cut -d' ' -f1)"
[ "$MODE" = "-rw-r--r--" ] || exit 78


ieddtab help : explain varlist is outcome vars

{smcl}
{* 19 Oct 2018}{...}
{hline}
help for {hi:ieddtab}
{hline}

{title:Title}

{phang2}{cmdab:ieddtab} {hline 2} This command runs a Diff-in-Diff regression and displays the baseline values, the two 1st differences and the 2nd difference.

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

{title:Syntax}

{phang2} {cmdab:ieddtab} {it:varlist},
	{cmdab:t:ime(}{it:varname}{cmd:)} {cmdab:treat:ment(}{it:varname}{cmd:)}
	[
		{cmdab:covar:iates(}{it:varlist}{cmd:)} {cmdab:starl:evels(}{it:numlist}{cmd:)}
		{cmdab:err:ortype(}{it:string}{cmd:)} {cmdab:rowl:abtype(}{it:string}{cmd:)}
		{cmdab:rowlabtext(}{it:label_string}{cmd:)} {cmdab:format(}{it:{help format:%fmt}}{cmd:)}
		{cmdab:replace} {cmdab:savet:ex(}{it:filepath}{cmd:)} {cmdab:onerow}
		{cmdab:nonotes} {cmdab:addn:otes(}{it:string}{cmd:)}  {cmdab:texdoc:ument}
		{cmdab:texc:aption(}{it:string}{cmd:)} {cmdab:texl:abel(}{it:string}{cmd:)}
		{cmdab:texn:otewidth(}{it:numlist}{cmd:)} {cmdab:texvspace(}{it:string}{cmd:)}
	]

{pmore}Where {it:varlist} is a list of numeric continuous outcome variables (also called dependable variables or left hand variables) to be used in the difference-in-difference regression(s) this command runs and presents the results from.{p_end}

{marker opts}{...}
{synoptset 24}{...}
{synopthdr:options}
{synoptline}
{pstd}{it:Required options:}{p_end}
{synopt :{cmdab:t:ime(}{it:varname}{cmd:)}}Time dummy to use in diff-in-diff regression{p_end}
{synopt :{cmdab:treat:ment(}{it:varname}{cmd:)}}Treatment dummy to use in diff-in-diff regression{p_end}

{pstd}{it:Statistics options:}{p_end}
{synopt :{cmdab:covar:iates(}{it:varlist}{cmd:)}}Covariates to use in diff-in-diff regression{p_end}
{synopt :{cmdab:vce:(}{it:{help vce_option:vce_types}}{cmd:)}}Options for variance estimation. {hi:Robust}, {hi:cluster} {it:clustervar} or {hi:bootstrap}{p_end}
{synopt :{cmdab:starl:evels(}{it:numlist}{cmd:)}}Significance levels used for significance stars, default values are .1, .05 and .01{p_end}
{synopt :{cmdab:err:ortype(}{it:string}{cmd:)}}Type of errors to display, default is standard errors.{p_end}

{pstd}{it:Output options:}{p_end}
{synopt :{cmdab:rowl:abtype(}{it:string}{cmd:)}}Indicate what to use as row titles, default is variable name.{p_end}
{synopt :{cmdab:rowlabtext(}{it:label_string}{cmd:)}}Manually enter the row titles using label strings (see below).{p_end}
{synopt :{cmdab:nonote}}Disable that the automatically generated note is displayed below the table.{p_end}
{synopt :{cmdab:addn:otes(}{it:string}{cmd:)}}Manually add a note to be displayed below the regression result table.{p_end}
{synopt :{cmdab:onerow}}Display the number of observations on one row at the last row of the table.{p_end}
{synopt :{cmdab:format(}{it:{help format:%fmt}}{cmd:)}}Set the rounding format of the calculated statistics in the table.{p_end}
{synopt :{cmdab:replace}}Replace the file on disk if it already exist. Has no effect if no option with file path is used.{p_end}

{pstd}{it:LaTeX options:}{p_end}
{synopt :{cmdab:savet:ex(}{it:filepath}{cmd:)}}Generate a LaTeX table of the result and save to the location of the file path.{p_end}
{synopt :{cmdab:texdoc:ument}}Creates a stand-alone TeX document.{p_end}
{synopt :{cmdab:texc:aption(}{it:string}{cmd:)}}Specify table's caption on TeX file.{p_end}
{synopt :{cmdab:texl:abel(}{it:string}{cmd:)}}Specify table's label, used for meta-reference across TeX file.{p_end}
{synopt :{cmdab:texn:otewidth(}{it:numlist}{cmd:)}}Manually enter the width of the note on the TeX file.{p_end}
{synopt :{cmd:texvspace(}{it:string}{cmd:)}}Manually set size of the line space between two rows on TeX output.{p_end}
{synoptline}

{marker desc}
{title:Description}

{pstd}{cmdab:ieddtab} is a command that makes it easy to run and display results of differences-in-differences (diff-in-diff) regressions. The table that presents the results from the diff-in-diff regression also presents the mean when the variable in {inp:time()} is 0 (i.e. baseline) for the two groups defined by the variable {inp:treatment()} is 0 and 1 (i.e. control and treatment), and the table also presents the coefficient of the first difference regression in control and treatment.{p_end}

{pstd}The sample for each row in the table is defined by the sample included in the second difference regression shown below, where {it:outcome_var} is a variable the varlist (one per row) for {inp:ieddtab}, {inp:`interaction'} is the interaction of the dummy listed in {inp:time()} and the dummy listed in {inp:treatment()}, and where {inp:`covariates'} is the list of covariates included in {inp:covariates()} if any. This means that any observation that has any missing value in either of the two dummies or in any of the covariates will be omitted from all statistics presented in the table. The coefficient presented in the table for the diff-in-diff regression is the interaction of the time and treatment variable.{p_end}

{pstd}{inp:tempvar} {it:interaction}{p_end}
{pstd}{inp:generate `interaction' = `time' * `treatment'}{p_end}
{pstd}{inp:regress} {it:outcome_var} {inp:`time' `treatment' `interaction' `covariates'}{p_end}

{pstd}The baseline means are then calculated using the following code where the first line is control and the second line is treatment, and the variable {inp:regsample} is dummy indicating if the observation was included in the second difference regression.{p_end}

{pstd}{inp:mean} {it:outcome_var} {inp:if `treatment' == 0 & `time' == 0 & regsample == 1}{p_end}
{pstd}{inp:mean} {it:outcome_var} {inp:if `treatment' == 1 & `time' == 0 & regsample == 1}{p_end}

{pstd}The first difference coefficients are then calculated using the following code where the first line is control and the second line is treatment. The coefficient displayed in the table is the coefficient of the variable `time' which is the variable listed in {inp:t()}.{p_end}

{pstd}{inp:regress} {it:outcome_var} {inp: `time' `covariates' if `treatment' == 0 & regsample == 1}{p_end}
{pstd}{inp:regress} {it:outcome_var} {inp: `time' `covariates' if `treatment' == 1 & regsample == 1}{p_end}

{marker optslong}
{title:Options}

{pstd}{it:{ul:{hi:Required options:}}}{p_end}
{phang}{cmdab:t(}{it:varname}{cmd:)} indicates which variable should be used as the time dummy to use in diff-in-diff regression. This must be a dummy variable, i.e. only have 0, 1 or missing as values, where 0 is baseline and 1 is follow-up.{p_end}

{phang}{cmdab:treatment(}{it:varname}{cmd:)} indicates which variable should be used as the treatment dummy to use in diff-in-diff regression. This must be a dummy variable, i.e. only have 0, 1 or missing as values.{p_end}

{pstd}{it:{ul:{hi:Statistics options:}}}{p_end}
{phang}{cmdab:covar:iates(}{it:varlist}{cmd:)} lists the variables that should be included as covariates (independent variables not reported in the table) in the two first difference regressions and the second diffrence regression. Unless the option {cmdab:nonotes} is used a list of covariate variables is included below the table.{p_end}

{phang}{cmdab:vce:(}{it:{help vce_option:vce_types}{cmd:)}} sets the type of variance estimator to be used in all regressions for this
command. See {help vce_option:vce_types} for more details. The only vce types allowed in this command are {hi:robust}, {hi:cluster} {it:clustervar} or {hi:bootstrap}.
Option {hi:robust} only applied to first and second difference estimators, not to baseline means.{p_end}

{phang}{cmdab:starl:evels(}{it:numlist}{cmd:)} sets the significance levels used for significance stars. Exactly three values must be listed if this option is used, all three values must be descending order, and must be between 0 and 1. The default values are .1, .05 and .01{p_end}

{phang}{cmdab:err:ortype(}{it:string}{cmd:)} sets the type of error to display. Allowed values for this iption is {inp:se} for standard errors, {inp:sd} for standard deviation and {inp:errhide} for not displaying any errors in the table. The default is to display standard errors.{p_end}

{pstd}{it:{ul:{hi:Output options:}}}{p_end}
{phang}{cmdab:rowl:abtype(}{it:string}{cmd:)} indicates what to use as row titles. The allowed values are {inp:varname} using the variable name as row titles, {inp:varlab} using the variable labels as row titles (varname will still be used if the variable does not have a variable label). The default is to use the variable name.{p_end}

{phang}{cmdab:rowlabtext(}{it:label_string}{cmd:)} manually specifies the row titles using label strings. A label string is a list of variable names followed by the row title for that variable separated by "@@". For example {it:varA Row title variable A @@ varB Row title variable B}, where {it:varA} and {it:varB} are outcome variables used in this command. For variable not listed in {cmdab:rowlabtext()} row titles will be determined by the input value or default value in {cmdab:rowl:abtype()}.{p_end}

{phang}{cmdab:nonotes} disable that the command automatically generates and displays a note below the table describing the output in the table. The note includes description on how number of calculations are calculated, the significance levels used for stars and which covariates were uses if any were used.{p_end}

{phang}{cmdab:addn:otes(}{it:string}{cmd:)} is used to manually add a note to be displayed below the regression result table. This note is put before the automatically generated note, unless option {cmdab:nonotes} is specified, in which case only the manually added note is displayed.{p_end}

{phang}{cmdab:onerow} indicated that the number of observations should be displayed on one row at the last row of the table instead on each row. This requires that the number of observations are the same across all rows for each column.{p_end}

{phang}{cmdab:format(}{it:{help format:%fmt}}{cmd:)} sets the number formatting/rounding rule for all calculated statistics in the table, that is all numbers in the table apart from the number of observations. Only valid {help format:Stata number formats} are allowed. The default is {it:%9.2f}.{p_end}

{phang}{cmdab:replace} if an option is used that output a file and a file with that name already exists at that location, then Stata will throw an error unless this option is used. If this option is used then Stata overwrites the file on disk with the new output. This option has no effect if no option with file path is used.{p_end}

{pstd}{it:{ul:{hi:LaTeX options:}}}{p_end}
{phang}{cmdab:savet:ex(}{it:filepath}{cmd:)} saves the table in TeX format to the location of the file path.{p_end}

{phang}{cmdab:texdoc:ument} creates a stand-alone TeX document that can be readily compiled, without the need to import it to a different file.
 As default, {cmd:savetex()} creates a fragmented TeX file consisting only of a tabular environment.

{phang}{cmdab:texc:aption(}{it:string}{cmd:)} writes table's caption in TeX file. Can only be used with option texdocument. {p_end}

{phang}{cmdab:texl:abel(}{it:string}{cmd:)} specifies table's label, used for meta-reference across TeX file. Can only be used with option texdocument.{p_end}

{phang}{cmdab:texn:otewidth(}{it:numlist}{cmd:)} manually adjusts the width of the note to fit the size of the table.
The note width is a multiple of text width. If not specified, default is one, which makes the table width equal to text width.{p_end}

{phang}{cmd:texvspace(}{it:string}{cmd:)} sets the size of the line space between two variable rows. {it:string} must consist of a numeric value
and one of the following units: "cm", "mm", "pt", "in", "ex" or "em". Note that the resulting line space displayed will be equal to the
specified value minus the height of one line of text. Default is "3ex". For more information on units,
{browse "https://en.wikibooks.org/wiki/LaTeX/Lengths":check LaTeX lengths manual}. {p_end}

{marker optslong}
{title:Examples}

{pstd}All the examples below can be run on the Stata's built in census data set, by first running this code:{p_end}

{pstd}*Open the built in data set{p_end}
{pstd}{inp:sysuse census}{p_end}

{pstd}*Calculate rates from absolute numbers{p_end}
{pstd}{inp:replace death = 100 * death / pop}{p_end}
{pstd}{inp:replace marriage = 100 * marriage / pop}{p_end}
{pstd}{inp:replace divorce = 100 * divorce / pop}{p_end}

{pstd}*Randomly assign time and treatment dummies{p_end}
{pstd}{inp:gen t	= (runiform()<.5)}{p_end}
{pstd}{inp:gen treatment = (runiform()<.5)}{p_end}

{pstd} {hi:Example 1.}

{pstd} {inp:ieddtab} {it:death marriage divorce} , {inp:t(}{it:time}{inp:)} {inp:treatment(}{it:treatment}{inp:)}

{pstd}This is the most basic way to run this command with three variables. This will output a table with the baseline means for treatment = 0 and treatment = 1, the first difference regression coefficient for treatment = 0 and treatment = 1 as well as the 2nd difference regression coefficient for treatment = 0 and treatment = 1.

{pstd} {hi:Example 2.}

{pstd} {inp:ieddtab} {it:death marriage divorce} ,  {inp:t(}{it:time}{inp:)} {inp:treatment(}{it:treatment}{inp:)}  {inp:rowlabtext(}{it:"death Death Rate @@ divorce Divorce Rate"}{inp:)} {inp:rowlabtype(}{it:"varlab"}{inp:)}

{pstd}The table generated by example 2 will have the same statistics as in example 1 but the row title for the variables death and divorce are entered manually and the row title for marriage will be its variable label instead of its variable name.

{pstd} {hi:Example 3.}

{pstd} {inp:ieddtab} {it:death marriage divorce} ,  {inp:t(}{it:time}{inp:)} {inp:treatment(}{it:treatment}{inp:)}  {inp:rowlabtype(}{it:"varlab"}{inp:)} {inp:savetex(}{it:"DID table.tex"}{inp:)} {inp:replace}

{pstd}The table will be saved in the current directory under the name "DID table.tex". It will will have the same statistics as in examples 1 and 2, and the row titles will be its variable labels.

{title:Acknowledgements}

{phang}This command was initally suggested by Esteban J. Quinones, University of Wisconsin-Madison{p_end}

{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}Benjamin Daniels{break}Jonas Guthoff{break}Nausheen Khan{break}Varnitha Kurli{break}Saori Iwamoto{break}Meyhar Mohammed{break}Michael Orevba{break}Matteo Ruzzante{break}Sakina Shibuya{break}Leonardo Viotti{break}

{title:Author}

{phang}All commands in ietoolkit is developed by DIME Analytics at DECIE, The World Bank's unit for Development Impact Evaluations.{p_end}

{phang}Main author: Kristoffer Bjarkefur, Luiza Cardoso De Andrade, DIME Analytics, The World Bank Group{p_end}

{phang}Please send bug-reports, suggestions and requests for clarifications
		 writing "ietoolkit ieddtab" in the subject line to:{break}
		 dimeanalytics@worldbank.org{p_end}

{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"}{p_end}

{smcl}
{* 19 Oct 2018}{...}
{hline}
help for {hi:ieddtab}
{hline}

{title:Title}

{phang2}{cmdab:ieddtab} {hline 2} This command runs a Diff-in-Diff regression and displays the baseline values, the two 1st differences and the 2nd difference.

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

{title:Syntax}

{phang2} {cmdab:ieddtab} {it:varlist},
	{cmdab:t:ime(}{it:varname}{cmd:)} {cmdab:treat:ment(}{it:varname}{cmd:)}
	[
		{cmdab:covar:iates(}{it:varlist}{cmd:)} {cmdab:starl:evels(}{it:numlist}{cmd:)}
		{cmdab:err:ortype(}{it:string}{cmd:)} {cmdab:rowl:abtype(}{it:string}{cmd:)}
		{cmdab:rowlabtext(}{it:label_string}{cmd:)} {cmdab:format(}{it:{help format:%fmt}}{cmd:)}
		{cmdab:replace} {cmdab:savet:ex(}{it:filepath}{cmd:)} {cmdab:onerow}
		{cmdab:nonotes} {cmdab:addn:otes(}{it:string}{cmd:)}  {cmdab:texdoc:ument}
		{cmdab:texc:aption(}{it:string}{cmd:)} {cmdab:texl:abel(}{it:string}{cmd:)}
		{cmdab:texn:otewidth(}{it:numlist}{cmd:)} {cmdab:texvspace(}{it:string}{cmd:)}
	]

{marker opts}{...}
{synoptset 24}{...}
{synopthdr:options}
{synoptline}
{pstd}{it:Required options:}{p_end}
{synopt :{cmdab:t:ime(}{it:varname}{cmd:)}}Time dummy to use in diff-in-diff regression{p_end}
{synopt :{cmdab:treat:ment(}{it:varname}{cmd:)}}Treatment dummy to use in diff-in-diff regression{p_end}

{pstd}{it:Statistics options:}{p_end}
{synopt :{cmdab:covar:iates(}{it:varlist}{cmd:)}}Covariates to use in diff-in-diff regression{p_end}
{synopt :{cmdab:vce:(}{it:{help vce_option:vce_types}}{cmd:)}}Options for variance estimation. {hi:Robust}, {hi:cluster} {it:clustervar} or {hi:bootstrap}{p_end}
{synopt :{cmdab:starl:evels(}{it:numlist}{cmd:)}}Significance levels used for significance stars, default values are .1, .05 and .01{p_end}
{synopt :{cmdab:err:ortype(}{it:string}{cmd:)}}Type of errors to display, default is standard errors.{p_end}

{pstd}{it:Output options:}{p_end}
{synopt :{cmdab:rowl:abtype(}{it:string}{cmd:)}}Indicate what to use as row titles, default is variable name.{p_end}
{synopt :{cmdab:rowlabtext(}{it:label_string}{cmd:)}}Manually enter the row titles using label strings (see below).{p_end}
{synopt :{cmdab:nonote}}Disable that the automatically generated note is displayed below the table.{p_end}
{synopt :{cmdab:addn:otes(}{it:string}{cmd:)}}Manually add a note to be displayed below the regression result table.{p_end}
{synopt :{cmdab:onerow}}Display the number of observations on one row at the last row of the table.{p_end}
{synopt :{cmdab:format(}{it:{help format:%fmt}}{cmd:)}}Set the rounding format of the calculated statistics in the table.{p_end}
{synopt :{cmdab:replace}}Replace the file on disk if it already exist. Has no effect if no option with file path is used.{p_end}

{pstd}{it:LaTeX options:}{p_end}
{synopt :{cmdab:savet:ex(}{it:filepath}{cmd:)}}Generate a LaTeX table of the result and save to the location of the file path.{p_end}
{synopt :{cmdab:texdoc:ument}}Creates a stand-alone TeX document.{p_end}
{synopt :{cmdab:texc:aption(}{it:string}{cmd:)}}Specify table's caption on TeX file.{p_end}
{synopt :{cmdab:texl:abel(}{it:string}{cmd:)}}Specify table's label, used for meta-reference across TeX file.{p_end}
{synopt :{cmdab:texn:otewidth(}{it:numlist}{cmd:)}}Manually enter the width of the note on the TeX file.{p_end}
{synopt :{cmd:texvspace(}{it:string}{cmd:)}}Manually set size of the line space between two rows on TeX output.{p_end}
{synoptline}

{marker desc}
{title:Description}

{pstd}{cmdab:ieddtab} is a command that makes it easy to run and display results of differences-in-differences (diff-in-diff) regressions. The table that presents the results from the diff-in-diff regression also presents the mean when the variable in {inp:time()} is 0 (i.e. baseline) for the two groups defined by the variable {inp:treatment()} is 0 and 1 (i.e. control and treatment), and the table also presents the coefficient of the first difference regression in control and treatment.{p_end}

{pstd}The sample for each row in the table is defined by the sample included in the second difference regression shown below, where {it:outcome_var} is a variable the varlist (one per row) for {inp:ieddtab}, {inp:`interaction'} is the interaction of the dummy listed in {inp:time()} and the dummy listed in {inp:treatment()}, and where {inp:`covariates'} is the list of covariates included in {inp:covariates()} if any. This means that any observation that has any missing value in either of the two dummies or in any of the covariates will be omitted from all statistics presented in the table. The coefficient presented in the table for the diff-in-diff regression is the interaction of the time and treatment variable.{p_end}

{pstd}{inp:tempvar} {it:interaction}{p_end}
{pstd}{inp:generate `interaction' = `time' * `treatment'}{p_end}
{pstd}{inp:regress} {it:outcome_var} {inp:`time' `treatment' `interaction' `covariates'}{p_end}

{pstd}The baseline means are then calculated using the following code where the first line is control and the second line is treatment, and the variable {inp:regsample} is dummy indicating if the observation was included in the second difference regression.{p_end}

{pstd}{inp:mean} {it:outcome_var} {inp:if `treatment' == 0 & `time' == 0 & regsample == 1}{p_end}
{pstd}{inp:mean} {it:outcome_var} {inp:if `treatment' == 1 & `time' == 0 & regsample == 1}{p_end}

{pstd}The first difference coefficients are then calculated using the following code where the first line is control and the second line is treatment. The coefficient displayed in the table is the coefficient of the variable `time' which is the variable listed in {inp:t()}.{p_end}

{pstd}{inp:regress} {it:outcome_var} {inp: `time' `covariates' if `treatment' == 0 & regsample == 1}{p_end}
{pstd}{inp:regress} {it:outcome_var} {inp: `time' `covariates' if `treatment' == 1 & regsample == 1}{p_end}

{marker optslong}
{title:Options}

{pstd}{it:{ul:{hi:Required options:}}}{p_end}
{phang}{cmdab:t(}{it:varname}{cmd:)} indicates which variable should be used as the time dummy to use in diff-in-diff regression. This must be a dummy variable, i.e. only have 0, 1 or missing as values, where 0 is baseline and 1 is follow-up.{p_end}

{phang}{cmdab:treatment(}{it:varname}{cmd:)} indicates which variable should be used as the treatment dummy to use in diff-in-diff regression. This must be a dummy variable, i.e. only have 0, 1 or missing as values.{p_end}

{pstd}{it:{ul:{hi:Statistics options:}}}{p_end}
{phang}{cmdab:covar:iates(}{it:varlist}{cmd:)} lists the variables that should be included as covariates (independent variables not reported in the table) in the two first difference regressions and the second diffrence regression. Unless the option {cmdab:nonotes} is used a list of covariate variables is included below the table.{p_end}

{phang}{cmdab:vce:(}{it:{help vce_option:vce_types}{cmd:)}} sets the type of variance estimator to be used in all regressions for this
command. See {help vce_option:vce_types} for more details. The only vce types allowed in this command are {hi:robust}, {hi:cluster} {it:clustervar} or {hi:bootstrap}.
Option {hi:robust} only applied to first and second difference estimators, not to baseline means.{p_end}

{phang}{cmdab:starl:evels(}{it:numlist}{cmd:)} sets the significance levels used for significance stars. Exactly three values must be listed if this option is used, all three values must be descending order, and must be between 0 and 1. The default values are .1, .05 and .01{p_end}

{phang}{cmdab:err:ortype(}{it:string}{cmd:)} sets the type of error to display. Allowed values for this iption is {inp:se} for standard errors, {inp:sd} for standard deviation and {inp:errhide} for not displaying any errors in the table. The default is to display standard errors.{p_end}

{pstd}{it:{ul:{hi:Output options:}}}{p_end}
{phang}{cmdab:rowl:abtype(}{it:string}{cmd:)} indicates what to use as row titles. The allowed values are {inp:varname} using the variable name as row titles, {inp:varlab} using the variable labels as row titles (varname will still be used if the variable does not have a variable label). The default is to use the variable name.{p_end}

{phang}{cmdab:rowlabtext(}{it:label_string}{cmd:)} manually specifies the row titles using label strings. A label string is a list of variable names followed by the row title for that variable separated by "@@". For example {it:varA Row title variable A @@ varB Row title variable B}, where {it:varA} and {it:varB} are outcome variables used in this command. For variable not listed in {cmdab:rowlabtext()} row titles will be determined by the input value or default value in {cmdab:rowl:abtype()}.{p_end}

{phang}{cmdab:nonotes} disable that the command automatically generates and displays a note below the table describing the output in the table. The note includes description on how number of calculations are calculated, the significance levels used for stars and which covariates were uses if any were used.{p_end}

{phang}{cmdab:addn:otes(}{it:string}{cmd:)} is used to manually add a note to be displayed below the regression result table. This note is put before the automatically generated note, unless option {cmdab:nonotes} is specified, in which case only the manually added note is displayed.{p_end}

{phang}{cmdab:onerow} indicated that the number of observations should be displayed on one row at the last row of the table instead on each row. This requires that the number of observations are the same across all rows for each column.{p_end}

{phang}{cmdab:format(}{it:{help format:%fmt}}{cmd:)} sets the number formatting/rounding rule for all calculated statistics in the table, that is all numbers in the table apart from the number of observations. Only valid {help format:Stata number formats} are allowed. The default is {it:%9.2f}.{p_end}

{phang}{cmdab:replace} if an option is used that output a file and a file with that name already exists at that location, then Stata will throw an error unless this option is used. If this option is used then Stata overwrites the file on disk with the new output. This option has no effect if no option with file path is used.{p_end}

{pstd}{it:{ul:{hi:LaTeX options:}}}{p_end}
{phang}{cmdab:savet:ex(}{it:filepath}{cmd:)} saves the table in TeX format to the location of the file path.{p_end}

{phang}{cmdab:texdoc:ument} creates a stand-alone TeX document that can be readily compiled, without the need to import it to a different file.
 As default, {cmd:savetex()} creates a fragmented TeX file consisting only of a tabular environment.

{phang}{cmdab:texc:aption(}{it:string}{cmd:)} writes table's caption in TeX file. Can only be used with option texdocument. {p_end}

{phang}{cmdab:texl:abel(}{it:string}{cmd:)} specifies table's label, used for meta-reference across TeX file. Can only be used with option texdocument.{p_end}

{phang}{cmdab:texn:otewidth(}{it:numlist}{cmd:)} manually adjusts the width of the note to fit the size of the table.
The note width is a multiple of text width. If not specified, default is one, which makes the table width equal to text width.{p_end}

{phang}{cmd:texvspace(}{it:string}{cmd:)} sets the size of the line space between two variable rows. {it:string} must consist of a numeric value
and one of the following units: "cm", "mm", "pt", "in", "ex" or "em". Note that the resulting line space displayed will be equal to the
specified value minus the height of one line of text. Default is "3ex". For more information on units,
{browse "https://en.wikibooks.org/wiki/LaTeX/Lengths":check LaTeX lengths manual}. {p_end}

{marker optslong}
{title:Examples}

{pstd}All the examples below can be run on the Stata's built in census data set, by first running this code:{p_end}

{pstd}*Open the built in data set{p_end}
{pstd}{inp:sysuse census}{p_end}

{pstd}*Calculate rates from absolute numbers{p_end}
{pstd}{inp:replace death = 100 * death / pop}{p_end}
{pstd}{inp:replace marriage = 100 * marriage / pop}{p_end}
{pstd}{inp:replace divorce = 100 * divorce / pop}{p_end}

{pstd}*Randomly assign time and treatment dummies{p_end}
{pstd}{inp:gen t	= (runiform()<.5)}{p_end}
{pstd}{inp:gen treatment = (runiform()<.5)}{p_end}

{pstd} {hi:Example 1.}

{pstd} {inp:ieddtab} {it:death marriage divorce} , {inp:t(}{it:time}{inp:)} {inp:treatment(}{it:treatment}{inp:)}

{pstd}This is the most basic way to run this command with three variables. This will output a table with the baseline means for treatment = 0 and treatment = 1, the first difference regression coefficient for treatment = 0 and treatment = 1 as well as the 2nd difference regression coefficient for treatment = 0 and treatment = 1.

{pstd} {hi:Example 2.}

{pstd} {inp:ieddtab} {it:death marriage divorce} ,  {inp:t(}{it:time}{inp:)} {inp:treatment(}{it:treatment}{inp:)}  {inp:rowlabtext(}{it:"death Death Rate @@ divorce Divorce Rate"}{inp:)} {inp:rowlabtype(}{it:"varlab"}{inp:)}

{pstd}The table generated by example 2 will have the same statistics as in example 1 but the row title for the variables death and divorce are entered manually and the row title for marriage will be its variable label instead of its variable name.

{pstd} {hi:Example 3.}

{pstd} {inp:ieddtab} {it:death marriage divorce} ,  {inp:t(}{it:time}{inp:)} {inp:treatment(}{it:treatment}{inp:)}  {inp:rowlabtype(}{it:"varlab"}{inp:)} {inp:savetex(}{it:"DID table.tex"}{inp:)} {inp:replace}

{pstd}The table will be saved in the current directory under the name "DID table.tex". It will will have the same statistics as in examples 1 and 2, and the row titles will be its variable labels.

{title:Acknowledgements}

{phang}This command was initally suggested by Esteban J. Quinones, University of Wisconsin-Madison{p_end}

{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}Benjamin Daniels{break}Jonas Guthoff{break}Nausheen Khan{break}Varnitha Kurli{break}Saori Iwamoto{break}Meyhar Mohammed{break}Michael Orevba{break}Matteo Ruzzante{break}Sakina Shibuya{break}Leonardo Viotti{break}

{title:Author}

{phang}All commands in ietoolkit is developed by DIME Analytics at DECIE, The World Bank's unit for Development Impact Evaluations.{p_end}

{phang}Main author: Kristoffer Bjarkefur, Luiza Cardoso De Andrade, DIME Analytics, The World Bank Group{p_end}

{phang}Please send bug-reports, suggestions and requests for clarifications
		 writing "ietoolkit ieddtab" in the subject line to:{break}
		 dimeanalytics@worldbank.org{p_end}

{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"}{p_end}