Add files via upload

Add files via upload

Creation of a training set in Stata

*merge together some true pairs

*prep  make two pairs datasets
cd R:\JoePriceResearch\record_linking\projects\deep_learning
use ark_pairs, clear
rename ark1 ark1900
rename ark2 ark1910
save ark_pairs1, replace
rename ark1900 ark
rename ark1910 ark1900
rename ark ark1910
save ark_pairs2, replace

global deeplearn "R:\JoePriceResearch\record_linking\projects\deep_learning"
global ark1 "R:\JoePriceResearch\record_linking\projects\deep_learning\ark_pairs1"
global ark2 "R:\JoePriceResearch\record_linking\projects\deep_learning\ark_pairs2"
global cen1900 "R:\JoePriceResearch\record_linking\data\census_1900\census1900_raw\done\statafiles"
global cen1910 "R:\JoePriceResearch\record_linking\data\census_1910\done\statafiles"

*1900
*grab some ohio
cd $cen1900
local dtas: dir . files "*.dta"
local i = 1
foreach dta of local dtas {
use `dta', clear
save sample/all`i'.dta, replace
local i = `i' + 1
}

cd sample
clear
local twostate: dir . files "all*"
foreach file of local twostate {
append using `file'
}
compress
*check duplicates
duplicates tag ark1900, gen(dup)
drop if dup > 0
drop dup
*add a 1900 subscript to each var
foreach var of varlist _all {
	if "`var'" == "ark1900" {
		continue
	}
	rename `var' `var'1900
}
*year has month. split
gen byear1900 = regexs(1) if regexm(birth_year1900,"([0-9][0-9][0-9][0-9])")
save all1900, replace

*1910
*grab some ohio
cd $cen1910
local dtas: dir . files "*.dta"
local i = 1
foreach dta of local dtas {
use `dta', clear
save sample/all`i'.dta, replace
local i = `i' + 1
}
cd sample
clear
local all: dir . files "all*"
foreach file of local all {
append using `file'
}
compress
*check for duplicates
duplicates tag ark1910, gen(dup)
*there are a lot more duplicates and a lot fewer observations.
drop if dup > 0
drop dup
*add a 1910 subscript to each var
foreach var of varlist _all {
	if "`var'" == "ark1910" {
		continue
	}
	rename `var' `var'1910
}
save all1910, replace

*start merging
cd $deeplearn
*1900
use ${cen1900}\sample\all1900, clear
merge 1:m ark1900 using ark_pairs1
keep if _merge == 3
compress
save cenpairs1900_1, replace
use ${cen1900}\sample\all1900, clear
merge 1:m ark1900 using ark_pairs2
keep if _merge == 3
compress
save cenpairs1900_2, replace
append using cenpairs1900_1
drop _merge
save cenpairs1900, replace
*1910
use ${cen1910}\sample\all1910, clear
merge 1:m ark1910 using ark_pairs1
keep if _merge == 3
compress
save cenpairs1910_1, replace
use ${cen1910}\sample\all1910, clear
merge 1:m ark1910 using ark_pairs2
keep if _merge == 3
compress
save cenpairs1910_2, replace
append using cenpairs1910_1
drop _merge
save cenpairs1910, replace

*now merge them together
merge m:1 ark1900 using cenpairs1900
keep if _merge == 3
drop _merge
gen similscore = 1
save all_sample_matches, replace

*so let's keep all of the 1910s and find potential matches
foreach var of varlist _all {
if strpos("`var'", "1900") {
	drop `var'
}
}
cap drop similscore
*start blocking
gen white = race == "white"
tostring white, gen(key)
drop white
replace key = key + birth_year1910 + gender1910 + substr(given_name1910, 1, 3) + substr(surname1910, 1, 2)
save tomatch1910, replace
*1900
use ${cen1900}\sample\all1900, clear
gen white = race == "white"
tostring white, gen(key)
drop white
replace key = key + byear1900 + gender1900 + substr(given_name1900, 1, 3) + substr(surname1900, 1, 2)
joinby key using tomatch1910

*set clusters
parallel setclusters 4
gen name_1900 = given_name1900 + " " + surname1900
gen name_1910 = given_name1910 + " " + surname1910
gen sort = _n
sort sort
parallel, by(sort) : matchit name_1900 name_1910
*drop perfect matches
drop if similscore == 1
append using all_sample_matches
*now drop out the true matches that didn't get a perfect score
gsort ark1910 ark1900 -similscore
drop if ark1900 == ark1900[_n-1] & ark1910 == ark1910[_n-1] & similscore != 1
gsort ark1910 -similscore
by ark1910: gen n = _N
gen match = similscore == 1
save all_sample_match_and_potential,replace

*now get some numeric features and export csv for some ML
gen white1900 = race1900 == "white"
gen white1910 = race1910 == "white"
gen racematch = white1900 == white1910
drop byear1900
gen byear1900 = regexs(1) if regexm(birth_year1900, "([0-9][0-9][0-9][0-9])")
gen yeardif = byear1900 - birth_year1910
gen year = byear1900
*month dummys
gen month = regexs(1) if regexm(birth_year1900, "([a-z][a-z][a-z])")
tabulate month, generate(mon)
local i = 1
foreach month in ///
"apr" ///
"aug" ///
"dev" ///
"feb" ///
"jan" ///
"jul" ///
"jun" ///
"mar" ///
"may" ///
"nov" ///
"oct" ///
"sep" ///
{
rename mon`i' `month'
local i = `i' + 1
}
*name scores
matchit given_name1900 given_name1910, gen(given_match)
matchit surname1900 surname1910, gen(surname_match)
*see if census state and county match
gen state1900 = reverse(regexs(1)) if regexm(reverse(census_place1900), ",([a-z .]+) ,")
cap gen state1910 = reverse(regexs(1)) if regexm(reverse(census_place1910), ",([a-z .]+) ,")
gen statematch = state1900 == state1910
gen county1900 = reverse(regexs(1)) if regexm(reverse(census_place1900), ",[a-z .]+ ,([a-z .]+) ,")
gen county1910 = reverse(regexs(1)) if regexm(reverse(census_place1910), ",[a-z .]+ ,([a-z .]+) ,")
gen countymatch = county1900 == county1910
gen relationshipmatch = relationship1900 == relationship1910
gen gender = gender1900

*outsheet the whole dataset
gsort -match -similscore
cd training_sets
local chunk_size = 250000
local total_files = ceil(_N / `chunk_size')
forval i = 1/`total_files' {
local j = `i' - 1
local upper = `i' * `chunk_size'
if `upper' > _N {
	local `upper' = _N
}
local lower = `j' * `chunk_size' + 1
outsheet _all using all_features_training`i'.csv in `lower'/`upper', replace delim("|")
}

keep match similscore *match gender apr aug dev feb jan jul jun mar may nov oct sep
outsheet _all using all_all_training.csv, comma

error: pathspec 'scripts/merge_census_pairs_all.do' did not match any file(s) known to git


Create cond_stitcher.ado

Create cond_stitcher.ado

cap pr drop cond_stitcher
pr def cond_stitcher, rclass
	// stitches together a long OR or AND statement given an array of dummy variables
	syntax anything , SEPerator(string)
	tokenize `anything'
	loc cond "if"
	while "`1'" != "" {
		if "`2'" == "" {
			loc separator ""
		}
		loc cond `cond' `1' `separator'
		macro shift
	}
	return local condition = "`cond'"
end

error: pathspec 'cond_stitcher.ado' did not match any file(s) known to git


iefolder : first setup

iefolder : first setup

first experimentation

fatal: unable to access 'https://github.com/worldbank/ietoolkit.git/': The requested URL returned error: 403


Create use_per_acre_graphs.do

Create use_per_acre_graphs.do

*set working directory

*set log file
log using "use_graphs.log"

*import data
use "data/use_acres_merged.dta"

*fix spaces
replace chemical_type=trim(chemical_type)
replace  crop=trim(crop)

*collapse by chemical type
collapse (sum) lbs_per_acre, by(year state crop chemical_type)

*graphs:

*US Fertilizer by crop
twoway (line lbs_per_acre year if chemical_type == "FERTILIZER" & crop == "SOYBEANS", lwidth(medthick)) (line lbs_per_acre year if chemical_type == "FERTILIZER" & crop == "CORN", lwidth(medthick)) (line lbs_per_acre year if chemical_type == "FERTILIZER" & crop == "COTTON", lwidth(medthick)) (line lbs_per_acre year if chemical_type == "FERTILIZER" & crop == "COTTON, UPLAND", lwidth(medthick)) if state == "UNITED STATES", ytitle(Lbs Applied Per Acre) xtitle(Year) title(Fertilizer Use Per Acre) subtitle(United States) legend(order(1 "Soybeans" 2 "Corn" 3 "Cotton" 4 "Upland Cotton"))
*US Pesticides by crop
twoway (line lbs_per_acre year if chemical_type == "HERBICIDE", lwidth(medthick)) (line lbs_per_acre year if chemical_type == "INSECTICIDE", lwidth(medthick)) (line lbs_per_acre year if chemical_type == "FUNGICIDE", lwidth(medthick)) if state == "UNITED STATES" & crop == "SOYBEANS", ytitle(Lbs Applied Per Acre) xtitle(Year) title(US Pesticide Use Per Acre) subtitle(Soybeans) legend(order(1 "Herbicide" 2 "Insecticide" 3 "Fungicide"))
twoway (line lbs_per_acre year if chemical_type == "HERBICIDE", lwidth(medthick)) (line lbs_per_acre year if chemical_type == "INSECTICIDE", lwidth(medthick)) (line lbs_per_acre year if chemical_type == "FUNGICIDE", lwidth(medthick)) if state == "UNITED STATES" & crop == "CORN", ytitle(Lbs Applied Per Acre) xtitle(Year) title(US Pesticide Use Per Acre) subtitle(Corn) legend(order(1 "Herbicide" 2 "Insecticide" 3 "Fungicide"))
twoway (line lbs_per_acre year if chemical_type == "HERBICIDE", lwidth(medthick)) (line lbs_per_acre year if chemical_type == "INSECTICIDE", lwidth(medthick)) (line lbs_per_acre year if chemical_type == "FUNGICIDE", lwidth(medthick)) if state == "UNITED STATES" & crop == "COTTON", ytitle(Lbs Applied Per Acre) xtitle(Year) title(US Pesticide Use Per Acre) subtitle(Cotton) legend(order(1 "Herbicide" 2 "Insecticide" 3 "Fungicide"))
twoway (line lbs_per_acre year if chemical_type == "HERBICIDE", lwidth(medthick)) (line lbs_per_acre year if chemical_type == "INSECTICIDE", lwidth(medthick)) (line lbs_per_acre year if chemical_type == "FUNGICIDE", lwidth(medthick)) if state == "UNITED STATES" & crop == "COTTON, UPLAND", ytitle(Lbs Applied Per Acre) xtitle(Year) title(US Pesticide Use Per Acre) subtitle(Upland Cotton) legend(order(1 "Herbicide" 2 "Insecticide" 3 "Fungicide"))

*Re-collapse for totals
collapse (sum) lbs_per_acre, by(year state chemical_type)

*US Fertilizer Total
twoway (line lbs_per_acre year if chemical_type == "FERTILIZER", lwidth(medthick)) if state == "UNITED STATES", ytitle(Lbs Applied Per Acre) xtitle(Year) title(Fertilizer Use Per Acre) subtitle(United States)

*US Pesticides Total
twoway (line lbs_per_acre year if chemical_type == "HERBICIDE", lwidth(medthick)) (line lbs_per_acre year if chemical_type == "FUNGICIDE", lwidth(medthick)) (line lbs_per_acre year if chemical_type == "INSECTICIDE", lwidth(medthick)) if state == "UNITED STATES", ytitle(Lbs Applied Per Acre) xtitle(Year) title(Pesticide Use Per Acre) subtitle(United States) legend(order(1 "Herbicides" 2 "Fungicides" 3 "Insecticides"))

error: pathspec 'use_per_acre_graphs.do' did not match any file(s) known to git


added qy fe

added qy fe

program reg_traf

local ln `1'
di "this is `ln'"

local int 1.treat#1.post#1.isbaseball
local x1 1.treat#1.post
local x2 1.isbaseball#1.post

est clear
use ${stash}master, clear

eststo: qui xtreg `ln'traf `x1' i.${fe} if isb==1, fe vce(robust)
qui estadd local fixed "Yes"
qui estadd local yearfe "Yes"

eststo: qui xtreg `ln'traf `x1' i.qy if isb==1, fe vce(robust)
qui estadd local fixed "Quality X Year"
qui estadd local yearfe "Yes"

eststo: qui xtreg `ln'traf `int' `x1' `x2' i.$fe, fe vce(robust)
qui estadd local fixed "Yes"
qui estadd local yearfe "Yes"

eststo: qui xtreg `ln'traf `int' `x1' `x2' i.qy, fe vce(robust)
qui estadd local fixed "Quality X Year"
qui estadd local yearfe "Yes"

esttab using "${tables}`ln'traf.tex", keep(`int' `x1' `x2') se ar2 nonotes star(+ 0.15 * 0.10 ** 0.05 *** 0.01) coeflabels(`int' "\emph{out-of-copy X post X baseball}" `x1' "\emph{out-of-copy X post}" `x2' "\emph{baseball X post}") order(`int' `x1' `x2') mtitles( "Traffic" "Traffic" "Traffic" "Traffic") replace booktabs s(fixed yearfe r2_a N N_g, label("Player FE" "Year FE" "adj. \$R^2\$" N "Clusters")) width(\hsize) staraux

end

error: pathspec 'scripts/stata/ado/reg_traf.ado' did not match any file(s) known to git


Redo file for config

Redo file for config

ask() {
  echo $1
  echo -n '> '
}

ask "Where is peregrine JSON API running?"
read peregrine
echo "peregrine: $peregrine" >> $3

while [ ! -e "$thinfrequencies" ]; do
  ask "Where is THIN frequencies file?"
  read thinfrequencies
done
echo "thinfrequencies: $thinfrequencies" >> $3

error: pathspec 'evaluation/config.yaml.do' did not match any file(s) known to git


add stata label generator script

add stata label generator script

** set up environment
capture log close
log using stata_labelling_log.log, replace

set more off

** this program outputs a labelling do file for each item group
** step 1 is get all the variable labels from metadata_crf_ig_item
** step 2 is get all the variable value labels from response_set_labels

** step 1
clear all

** load the item definitions file
use "metadata_crf_ig_item.dta"

** generate the variable labelling commands
gen varlabel = "lab var " + lower(item_name) + `" ""' + item_description + `"""'

** make an ordering variable
gen order = _n

** tag the first occurrence of each labelling command, use item_oid in case item_name is reused
by varlabel item_oid (order), sort: gen varlabel_first = _n == 1

** tag the first occurrence of each item group oid
by item_group_oid (order), sort: gen item_group_oid_first = _n == 1

** get the observation count in a local macro
su order, meanonly
local obscount `r(max)'

** loop through each unique item group, note that i is the observation number
forvalues i=1/`obscount' {

	** only act on each item group once
	if item_group_oid_first[`i'] == 1 {

		** store the current item group oid for reuse
		scalar item_group_oid_current = item_group_oid[`i']

		** create a short but unique name for the file handle
		local file_handle=substr(item_group_oid_current,1,8)

		** create the file name
		local file_name=item_group_oid_current+"_labels.do"

		** open the file for replace, name it using the full item group name
		file open `file_handle' using `file_name', write replace

		** loop through each command list and write it, followed by a newline
		forvalues j=1/`obscount' {

			** store the current varlabel for reuse
			scalar varlabel_current = varlabel[`j']

			** only act on each varlabel once
			if item_group_oid[`j'] == item_group_oid_current & varlabel_first[`j'] == 1 {

				** write the varlabel to the file, followed by a newline
				file write `file_handle' (varlabel_current) _n
			}
		}
		** close the file and move on to the next item group, if any
		file close `file_handle'
	}
}

** step 2
clear

** load the response labels file
use "response_set_labels.dta"

** generate the label variable labelling commands
gen varlabel = "lab var " + lower(item_name) + `"_label ""' + item_description + `" label""'

** generate the value labelling commands
gen vallabel = "lab def " + lower(item_name) + "_lbl " + option_value + `" ""' + option_text + `"", modify"'

** generate the value labelling apply commands
gen valvarlbl = "lab val " + lower(item_name) + " " + lower(item_name) + "_lbl"

** make an ordering variable
gen order = _n

** tag the first occurrence of each varlabel command, use item_oid in case item_name is reused
by varlabel item_oid (order), sort: gen varlabel_first = _n == 1

** tag the first occurrence of each vallabel command, use item_oid in case item_name is reused
by vallabel item_oid (order), sort: gen vallabel_first = _n == 1

** tag the first occurrence of each valvarlbl command, use item_oid in case item_name is reused
by valvarlbl item_oid (order), sort: gen valvarlbl_first = _n == 1

** tag the first occurrence of each item group oid
by item_group_oid (order), sort: gen item_group_oid_first = _n == 1

** get the observation count in a local macro
su order, meanonly
local obscount `r(max)'

** loop through each unique item group, note that i is the observation number
forvalues i=1/`obscount' {

	** only act on each item group once
	if item_group_oid_first[`i'] == 1 {

		** store the current item group oid for reuse
		scalar item_group_oid_current = item_group_oid[`i']

		** create a short but unique name for the file handle
		local file_handle=substr(item_group_oid_current,1,8)

		** create the file name
		local file_name=item_group_oid_current+"_labels.do"

		** open the file for replace, name it using the full item group name
		file open `file_handle' using `file_name', write append

		** loop through each varlabel command and write it, followed by a newline
		forvalues j=1/`obscount' {

			** store the current varlabel for reuse
			scalar varlabel_current = varlabel[`j']

			** only act on each varlabel once
			if item_group_oid[`j'] == item_group_oid_current & varlabel_first[`j'] == 1 {

				** write the varlabel to the file, followed by a newline
				file write `file_handle' (varlabel_current) _n
			}
		}

		** loop through each vallabel command and write it, followed by a newline
		forvalues k=1/`obscount' {

			** store the current vallabel for reuse
			scalar vallabel_current = vallabel[`k']

			** only act on each vallabel once
			if item_group_oid[`k'] == item_group_oid_current & vallabel_first[`k'] == 1 {

				** write the vallabel to the file, followed by a newline
				file write `file_handle' (vallabel_current) _n
			}
		}

		** loop through each vallabel command and write it, followed by a newline
		forvalues l=1/`obscount' {

			** store the current valvarlbl for reuse
			scalar valvarlbl_current = valvarlbl[`l']

			** only act on each valvarlbl once
			if item_group_oid[`l'] == item_group_oid_current & valvarlbl_first[`l'] == 1 {

				** write the valvarlbl to the file, followed by a newline
				file write `file_handle' (valvarlbl_current) _n
			}
		}

		** close the file and move on to the next item group, if any
		file close `file_handle'
	}
}

** close the log file
log close

error: pathspec 'clients/stata_label_generator.do' did not match any file(s) known to git


Better tree

Better tree

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/dreameater89/d3_testing.git/'


added hlint do file

added hlint do file

error: pathspec 'src/hlint.do' did not match any file(s) known to git


copied code from prev project

copied code from prev project

fatal: unable to access 'https://github.com/dalek2point3/wikibaseball.git/': The requested URL returned error: 403


update hh infra

update hh infra

/*-------------------------------------------------------------------------------
# Name:		04_shocks
# Purpose:	Create preliminary analysis Uganda
# Author:	Tim Essam, Ph.D.
# Created:	01/12/2015
# Owner:	USAID GeoCenter | OakStream Systems, LLC
# License:	MIT License
# Ado(s):	see below
#-------------------------------------------------------------------------------
*/

capture log close
log using "$pathlog/05_hhchar", replace
use "$pathraw/GSEC9A.dta", clear

* Type of dwelling
g byte hutDwelling = (h9q1 == 7)
la var hutDwelling "Household dwelling is a hut"

* g byte hh owns dwelling
g byte ownDwelling = inlist(h9q2, 1, 2, 3)
la var ownDwelling "hh owns dwelling"

* g dwelling rooms size
clonevar dwellingSize = h9q3
recode dwellingSize (0 = 1)

* metal roof
g byte metalRoof = inlist(h9q4, 4, 7, 8, 10) == 1
la var metalRoof "dwelling has a metal/tin roof"

* mud home/hut?
g byte mudDwelling = inlist(h9q5, 1, 2, 3) == 1
la var mudDwelling "dwelling is made primarily of mud"

* Dirt floor?
g byte dfloor = inlist(h9q6, 1, 2) == 1
la var dfloor "dwelling has mud/dirt/earth floor"

* HH has protected water source
g byte protWater = inlist(h9q7, 1, 2, 3, 4, 5) == 1
la var protWater "hh has protected water source"

* Time to get drinking water
g waterTime = (h9q9a+ h9q9b)
la var waterTime "Total time required to get drinking water"

* Distance to water source
clonevar waterDist = h9q10

* HH purchase water used
clonevar waterPay = h9q12
recode waterPay (2 = 0)

* What does hh do to make water safe
g byte safeWater = inlist(h9q17, 1, 2, 3) == 1
la var safeWater "hh boil/filters water to make water safe"

*************
* Sanitation*
*************

* HH has private, covered latrine
g byte latrineCovered = inlist(h9q22, 5, 8) != 1

* HH has hand-washing facility at toilet
g byte latrineWash = (h9q23 != 1)

la var latrineCovered "hh has access to covered latrine"
la var latrineWash "hand washing station facility at toilet"

* Save create variables and collapse
ds(h9q*), not
keep `r(varlist)'

* Copy variable labels to reapply after collapse
include "$pathdo2/copylabels.do"

ds(HHID), not
collapse (max) 	`r(varlist)', by(HHID)

* Reapply variable lables & value labels
include "$pathdo2/attachlabels.do"

* Save data
save "$pathout/hhinfra_tmp", replace

* Create energy use variables
use "$pathraw/GSEC10A.dta", clear

* House has electricity
clonevar electricity = h10q1
recode electricity (2 = 0)

* Stove used by hh
g byte openFire = h10q9 == 8
la var openFire "hh uses open fire for stove"

g byte outdoorStove = h10q12 == 3
la var outdoorStove "hh has outdoor stove"

ds(h10q*), not
keep `r(varlist)'

save "$pathout/hhenergy.dta", replace

* Load in asset module

error: pathspec 'Stata/05_hhinfra.do' did not match any file(s) known to git


ieddtab : first draft helpfile

ieddtab : first draft helpfile

{smcl}
{* 26 Apr 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(}{it:varname}{cmd:)} {cmdab:tmt(}{it:varname}{cmd:)}
	[
		{cmdab:covar:iates(}{it:varlist}{cmd:)} {cmdab:star:levels(}{it:numlist}{cmd:)}
		{cmdab:err:ortype(}{it:string}{cmd:)} {cmdab:rowl:abtype(}{it:string}{cmd:)}
		{cmdab:rowlabtext(}{it:label_string}{cmd:)} {cmdab:dif:ormat(}{it:{help format:%fmt}}{cmd:)}
		{cmdab:replace} {cmdab:savet:ex(}{it:filepath}{cmd:)} {cmdab:onerow}
		{cmdab:tblnon:ote} {cmdab:tbln:ote(}{it:string}{cmd:)}  {cmdab:texdoc:ument}
		{cmdab:texc:aption(}{it:string}{cmd:)} {cmdab:texl:able(}{it:string}{cmd:)}
		{cmdab:texn:otewidth(}{it:numlist}{cmd:)}
	]

{marker opts}{...}
{synoptset 24}{...}
{synopthdr:options}
{synoptline}
{pstd}{it:Required options:}{p_end}
{synopt :{cmdab:t(}{it:varname}{cmd:)}}Time dummy to use in diff-in-diff regression{p_end}
{synopt :{cmdab:tmt(}{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:star:levels(}{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:tblnon:ote}}Disable that the automatically generated note is displayed below the table.{p_end}
{synopt :{cmdab:tbln:ote(}{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:dif:ormat(}{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}}LUIZA{p_end}
{synopt :{cmdab:texc:aption(}{it:string}{cmd:)}}LUIZA{p_end}
{synopt :{cmdab:texl:able(}{it:string}{cmd:)}}LUIZA{p_end}
{synopt :{cmdab:texn:otewidth(}{it:numlist}{cmd:)}}LUIZA{p_end}
{synoptline}

{marker desc}
{title:Description}

{pstd}{cmdab:commandname} is a command that ...{p_end}

{pstd}Second paragraph{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.{p_end}

{phang}{cmdab:tmt(}{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:tblnon:ote} is used a list of covariate variables is included below the table.{p_end}

{phang}{cmdab:star:levels(}{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 enter 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:tblnon:ote} 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:tbln:ote(}{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 {cmdab:tblnon:ote} is displayed when 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:dif:ormat(}{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:)}Generate a LaTeX table of the result and save to the location of the file path.{p_end}

{phang}{cmdab:texdoc:ument}LUIZA{p_end}

{phang}{cmdab:texc:aption(}{it:string}{cmd:)}LUIZA{p_end}

{phang}{cmdab:texl:able(}{it:string}{cmd:)}LUIZA{p_end}

{phang}{cmdab:texn:otewidth(}{it:numlist}{cmd:)}LUIZA{p_end}

{marker optslong}
{title:Examples}

{pstd} {hi:Example 1.}

{pmore} {inp:ieddtab}

{pstd} {hi:Example 2.}

{pmore} {inp:ieddtab}

{pstd} {hi:Example 3.}

{pmore} {inp:ieddtab}

{title:Acknowledgements}

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

{title:Author}

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

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

{phang}Please send bug-reports, suggestions and requests for clarifications
		 writing "ietoolkit commandname" in the subject line to:{break}
		 dimeanalytics@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"}

error: pathspec 'src/help_files/ieddtab.sthlp' did not match any file(s) known to git


Pushed from nova Sun Nov  8 22:50:24 PST 2015

error: pathspec 'to.do' did not match any file(s) known to git


Update and rename Stata to Stata/03_health.do

/*------------------------------------------------------------------------------
# Name:		03_health
# Purpose:	Process household health and child nutrition information
# Author:	Tim Essam
# Created:	2015/2/26
# License:	MIT License
# Ado(s):	labutil, labutil2 (ssc install labutil, labutil2)
# Dependencies: copylables, attachlabels, 00_SetupFoldersGlobals.do
#-------------------------------------------------------------------------------
*/

clear
capture log close
log using "$pathlog/03_health", replace
di in yellow "`c(current_date)' `c(current_time)'"

use "$pathraw/GSEC5.dta", replace

* Household illness in past 30 days
g byte illness = (h5q4 == 1)

* Total costs for household due to illness
egen medCosts = total(h5q12), by(HHID)

* Costs per capita
bys HHID: g byte hhtmp = (inlist(h5q12, 0, .)!=1)
egen hhtmptot = total(hhtmp), by(HHID)
g medCostspc = medCosts/hhtmptot

* Total household time lost due to illness
egen medTime = total(h5q6), by(HHID)

* Label variables
la var illness "HH member sick in past 30 days"
la var medCosts "Total hh medical costs"
la var medCostspc "Per capital medical costs"
la var medTime "Total hh time lost due to illness"

error: pathspec 'Stata/03_health.do' did not match any file(s) known to git


Added .mata sample for Stata.

Added .mata sample for Stata.

Source: http://www.stata.com/help.cgi?m1_first

numeric matrix tanh(numeric matrix u)
{
		numeric matrix  eu, emu

		eu = exp(u)
		emu = exp(-u)
		return( (eu-emu):/(eu+emu) )
}

error: pathspec 'samples/Stata/tanh.mata' did not match any file(s) known to git


TST: Add SARIMAX coverage results Stata script

// Dataset
use http://www.stata-press.com/data/r12/wpi1, clear
rename t time

set more off
set maxiter 100

// 25, 43, 48, 52

// Create data for exog test
gen x = (wpi - floor(wpi))^2

// Create data for deterministic trend tests
gen c = 1
gen t = _n
gen t2 = t^2
gen t3 = t^3

// Dummy column for saving LLFs
gen mod = ""
gen llf = .
gen parameters = ""

// Program to save the results
program drop save_results
program save_results
    args i
    replace mod = e(cmdline) in `i'
    replace llf = e(ll) in `i'

    matrix b = e(b)
    local params = ""
    local params = string(b[1,1])
    local nparams = e(k)
    if `nparams' > 1 {
        foreach j of numlist 2/`nparams' {
            local params = "`params'," + string(b[1,`j'])
        }
    }
    replace parameters = "`params'" in `i'
end

// AR: (p,0,0) x (0,0,0,0)
capture arima wpi, arima(3,0,0) noconstant vce(oim)
save_results 1

// AR and deterministic trends ('nc', 'c', 'ct', polynomial)

// 'c'
capture arima wpi c, arima(3,0,0) noconstant vce(oim)
save_results 2

// 'ct'
capture arima wpi c t, arima(3,0,0) noconstant vce(oim)
save_results 3

// polynomial [1,0,0,1]
capture arima wpi c t3, arima(3,0,0) noconstant vce(oim)
save_results 4

// AR and I(d): (p,d,0) x (0,0,0,0)
capture arima wpi, arima(3,2,0) noconstant vce(oim)
save_results 5

// AR and I(D): (p,0,0) x (0,D,0,s)
capture arima wpi, arima(3,0,0) sarima(0,2,0,4) noconstant vce(oim)
save_results 6

// AR and diffuse initialization
capture arima wpi, arima(3,0,0) noconstant vce(oim) diffuse
save_results 7

// ARX
capture arima wpi x, arima(3,0,0) noconstant vce(oim)
save_results 8

// MA: (0,0,q) x (0,0,0,0)
capture arima wpi, arima(0,0,3) noconstant vce(oim)
save_results 9

// MA and deterministic trends ('nc', 'c', 'ct', polynomial)

// 'c'
capture arima wpi c, arima(0,0,3) noconstant vce(oim)
save_results 10

// 'ct'
capture arima wpi c t, arima(0,0,3) noconstant vce(oim)
save_results 11

// polynomial [1,0,0,1]
capture arima wpi c t3, arima(0,0,3) noconstant vce(oim)
save_results 12

// MA and I(d): (0,d,q) x (0,0,0,0)
capture arima wpi, arima(0,2,3) noconstant vce(oim)
save_results 13

// MA and I(D): (p,0,0) x (0,D,0,s)
capture arima wpi, arima(0,0,3) sarima(0,2,0,4) noconstant vce(oim)
save_results 14

// MA and diffuse initialization
capture arima wpi, arima(0,0,3) noconstant vce(oim) diffuse
save_results 15

// MAX
capture arima wpi x, arima(0,0,3) noconstant vce(oim)
save_results 16

// ARMA: (p,0,q) x (0,0,0,0)
capture arima wpi, arima(3,0,3) noconstant vce(oim)
save_results 17

// ARMA and deterministic trends ('nc', 'c', 'ct', polynomial)

// 'c'
capture arima wpi c, arima(3,0,2) noconstant vce(oim)
save_results 18

// 'ct'
capture arima wpi c t, arima(3,0,2) noconstant vce(oim)
save_results 19

// polynomial [1,0,0,1]
capture arima wpi c t3, arima(3,0,2) noconstant vce(oim)
save_results 20

// ARMA and I(d): (p,d,q) x (0,0,0,0)
capture arima wpi, arima(3,2,2) noconstant vce(oim)
save_results 21

// ARMA and I(D): (p,0,q) x (0,D,0,s)
capture arima wpi, arima(3,0,2) sarima(0,2,0,4) noconstant vce(oim)
save_results 22

// ARMA and I(d) and I(D): (p,d,q) x (0,D,0,s)
capture arima wpi, arima(3,2,2) sarima(0,2,0,4) noconstant vce(oim)
save_results 23

// ARMA and diffuse initialization
capture arima wpi, arima(3,0,2) noconstant vce(oim) diffuse
save_results 24

// ARMAX
capture arima wpi x, arima(3,0,2) noconstant vce(oim)
save_results 25

// SAR: (0,0,0) x (P,0,0,s)
capture arima wpi, sarima(3,0,0,4) noconstant vce(oim)
save_results 26

// SAR and deterministic trends ('nc', 'c', 'ct', polynomial)

// 'c'
capture arima wpi c, sarima(3,0,0,4) noconstant vce(oim)
save_results 27

// 'ct'
capture arima wpi c t, sarima(3,0,0,4) noconstant vce(oim)
save_results 28

// polynomial [1,0,0,1]
capture arima wpi c t3, sarima(3,0,0,4) noconstant vce(oim)
save_results 29

// SAR and I(d): (0,d,0) x (P,0,0,s)
capture arima wpi, arima(0,2,0) sarima(3,0,0,4) noconstant vce(oim)
save_results 30

// SAR and I(D): (0,0,0) x (P,D,0,s)
capture arima wpi, sarima(3,2,0,4) noconstant vce(oim)
save_results 31

// SAR and diffuse initialization
capture arima wpi, sarima(3,0,0,4) noconstant vce(oim) diffuse
save_results 32

// SARX
capture arima wpi x, sarima(3,0,0,4) noconstant vce(oim)
save_results 33

// SMA
capture arima wpi, sarima(0,0,3,4) noconstant vce(oim)
save_results 34

// SMA and deterministic trends ('nc', 'c', 'ct', polynomial)

// 'c'
capture arima wpi c, sarima(0,0,3,4) noconstant vce(oim)
save_results 35

// 'ct'
capture arima wpi c t, sarima(0,0,3,4) noconstant vce(oim)
save_results 36

// polynomial [1,0,0,1]
capture arima wpi c t3, sarima(0,0,3,4) noconstant vce(oim)
save_results 37

// SMA and I(d): (0,d,0) x (0,0,Q,s)
capture arima wpi, arima(0,2,0) sarima(0,0,3,4) noconstant vce(oim)
save_results 38

// SAR and I(D): (0,0,0) x (0,D,Q,s)

capture arima wpi, sarima(0,2,3,4) noconstant vce(oim)
save_results 39

// SMA and diffuse initialization
capture arima wpi, sarima(0,0,3,4) noconstant vce(oim) diffuse
save_results 40

// SMAX
capture arima wpi x, sarima(0,0,3,4) noconstant vce(oim)
save_results 41

// SARMA: (0,0,0) x (P,0,Q,s)
capture arima wpi, sarima(3,0,2,4) noconstant vce(oim)
save_results 42

// SARMA and deterministic trends ('nc', 'c', 'ct', polynomial)

// 'c'
capture arima wpi c, sarima(3,0,2,4) noconstant vce(oim)
save_results 43

// 'ct'
capture arima wpi c t, sarima(3,0,2,4) noconstant vce(oim)
save_results 44

// polynomial [1,0,0,1]
capture arima wpi c t3, sarima(3,0,2,4) noconstant vce(oim)
save_results 45

// SARMA and I(d): (0,d,0) x (P,0,Q,s)
capture arima wpi, arima(0,2,0) sarima(3,0,2,4) noconstant vce(oim)
save_results 46

// SARMA and I(D): (0,0,0) x (P,D,Q,s)
capture arima wpi, sarima(3,2,2,4) noconstant vce(oim)
save_results 47

// SARMA and I(d) and I(D): (0,d,0) x (P,D,Q,s)
capture arima wpi, arima(0,2,0) sarima(3,2,2,4) noconstant vce(oim)
save_results 48

// SARMA and diffuse initialization
capture arima wpi, sarima(3,0,2,4) noconstant vce(oim) diffuse
save_results 49

// SARMAX
capture arima wpi x, sarima(3,0,2,4) noconstant vce(oim)
save_results 50

// SARIMAX and exogenous
capture arima wpi x, arima(3,2,2) sarima(3,2,2,4) noconstant vce(oim)
save_results 51

// SARIMAX and exogenous and diffuse
capture arima wpi x, arima(3,2,2) sarima(3,2,2,4) noconstant vce(oim) diffuse
save_results 52

// ARMA and exogenous and trend polynomial and missing
gen wpi2 = wpi
gen t32 = (t-1)^3
replace wpi2 = . in 10/19
capture arima D.wpi2 t32 x, arima(3,0,2) noconstant vce(oim)
save_results 53

// Write results
outsheet mod llf parameters using "results_sarimax_coverage.csv" in 1/53, comma replace

error: pathspec 'dismalpy/ssm/tests/results/test_sarimax_coverage.do' did not match any file(s) known to git


Additional code.

Additional code.

error: pathspec '6-StataLaTeX/StataLaTeX' did not match any file(s) known to git
error: pathspec '2.do' did not match any file(s) known to git


package.do: only redo install if the system is supported

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/pombredanne/redo.git/'


-stgit- calls the correct subroutine based on Stata version

pr stgit, rclass
	vers 9.2

	loc command = cond(_caller() >= 13, "stgit13", "stgit9")
	vers `=_caller()': `command' `0'
	ret add
end

error: pathspec 'stgit/stgit.ado' did not match any file(s) known to git


ui-macos/git-export.do: write the generated app to a branch.

# update a local branch with pregenerated output files, so people can download
# the completed tarballs from github.  Since we don't have any real binaries,
# our final distribution package contains mostly blobs from the source code,
# so this doesn't cost us much extra space in the repo.
BRANCH=dist/macos
redo-ifchange 'Sshuttle VPN.app'
git update-ref refs/heads/$BRANCH origin/$BRANCH '' 2>/dev/null || true

export GIT_INDEX_FILE=$PWD/gitindex.tmp
rm -f "$GIT_INDEX_FILE"
git add -f 'Sshuttle VPN.app'

MSG="MacOS precompiled app package for $(git describe)"
TREE=$(git write-tree --prefix=ui-macos)
git show-ref refs/heads/$BRANCH >/dev/null && PARENT="-p refs/heads/$BRANCH"
COMMITID=$(echo "$MSG" | git commit-tree $TREE $PARENT)

git update-ref refs/heads/$BRANCH $COMMITID
rm -f "$GIT_INDEX_FILE"

error: pathspec 'ui-macos/git-export.do' did not match any file(s) known to git


Fix Documentation/md-to-man no-op when various libraries are missing


Create foodcourt.do

Create foodcourt.do

replace time_of_day ="" if time_of_day =="#VALUE!"
replace time = subinstr(time, " PM", "", .)
replace time = subinstr(time, " AM", "", .)
drop if time == "FOOD COURT CLOSED"
drop if time == "FOOD COURT "

clonevar time2 = time
replace time2 = subinstr(time2, ":", "", .)
destring time2, replace
replace time2 = time2 + 1200 if time_of_day == "PM" & time2 >=100 & time2 <= 1000

gen double mdate = monthly(month , "M")
gen dow = dow( mdy( month, day, year) )

error: pathspec 'foodcourt.do' did not match any file(s) known to git


Add ancilliary program -estfe-

Add ancilliary program -estfe-

Allows estout with reghdfe

fatal: unable to access 'https://github.com/sergiocorreia/reghdfe.git/': The requested URL returned error: 403


all.do

all.do

fatal: unable to access 'https://github.com/crypto-agda/crypto-agda.git/': The requested URL returned error: 403


Create 01_ZMB_DHSWealthIndex_merge.do

Create 01_ZMB_DHSWealthIndex_merge.do

fatal: unable to access 'https://github.com/tessam30/Zambia.git/': The requested URL returned error: 403


html.do

html.do

exec 1>&2
agda-pkg -cagda-pkg.conf --html crypto-agda.agda

error: pathspec 'html.do' did not match any file(s) known to git


vars.do: an improvement on the previous patch.

It would still loop infinitely if a string was "master " (trailing space).

redo-ifchange gitvars prodname

read PROD <prodname

exec <gitvars
read COMMIT
read NAMES
read DATE

# the list of names is of the form:
#   (x,y,tag: $PROD-####,tag: $PROD-####,a,b)
# The entries we want are the ones starting with "tag: $PROD-" since those
# refer to the right actual git tags.
names_to_tag()
{
	x=${1#\(}
	x=${x%\)}
	cur=
	while [ "$cur" != "$x" ]; do
		x=${x# }
		x=${x#tag: }
		cur=${x%%,*}
		tagpost=${cur#$PROD-}
		if [ "$cur" != "$tagpost" ]; then
			echo "$tagpost"
			return 0
		fi
		x=${x#*,}
	done
	commitpost=${COMMIT#???????}
	commitpre=${COMMIT%$commitpost}
	echo "unknown-$commitpre"
}

sTAG=$(names_to_tag "$NAMES")

echo "COMMIT='$COMMIT'"
echo "TAG='$sTAG'"
echo "DATE='${DATE%% *}'"

redo-ifchange gitvars prodname

read PROD <prodname

exec <gitvars
read COMMIT
read NAMES
read DATE

# the list of names is of the form:
#   (x,y,tag: $PROD-####,tag: $PROD-####,a,b)
# The entries we want are the ones starting with "tag: $PROD-" since those
# refer to the right actual git tags.
names_to_tag()
{
	x=${1#\(}
	x=${x%\)}
	cur=
	while [ "$cur" != "$x" ]; do
		x=${x# }
		cur=${x%%,*}
		cur=${cur#tag: }
		cur=${cur# }
		tagpost=${cur#$PROD-}
		if [ "$cur" != "$tagpost" ]; then
			echo "$tagpost"
			return 0
		fi
		x=${x#*,}
	done
	commitpost=${COMMIT#???????}
	commitpre=${COMMIT%$commitpost}
	echo "unknown-$commitpre"
}

sTAG=$(names_to_tag "$NAMES")

echo "COMMIT='$COMMIT'"
echo "TAG='$sTAG'"
echo "DATE='${DATE%% *}'"


use proper extension

use proper extension

#!/bin/sh
rm -f $(sed 's}^}bin/}' < BIN) $(find $(dirname $0) -path ./t -prune -o -type f -name '*~')

error: pathspec '@clean.do' did not match any file(s) known to git


Follow up on the comments for the code

Follow up on the comments for the code

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/kbuzard/political-uncertainty.git/'


Signed-off-by: mlick <2010lixiangxin@163.com>

error: pathspec 'images/billQuery2.do' did not match any file(s) known to git


Added package.do to create system packages using fpm


add N row to table

add N row to table

not sure if this is the best way to deal with N for 1st difference

cap program drop 	ieddtable
	program define	ieddtable

	syntax varlist, ///
					///
		t(varname numeric) tmt(varname numeric) 			///
		[ 													///
		COVARiates(varlist numeric)							///
		STARLevels(numlist descending min=3 max=3 >0 <1)	///
		STARSNOadd											///
		firstdiff											///
		rowlabtype(string) 									///
		rowlabtext(string)									///
		errortype(string)									///
		]

	/*************

		Input handling

	*************/

	*LABELS
	*Test and prepare the row lables and test how long the longest label is.
	prepRowLabels `varlist', rowlabtype("`rowlabtype'") rowlabtext("`rowlabtext'")
	local rowlabels "`r(rowlabels)'"
	local labmaxlen "`r(rowlabel_maxlen)'"

	*ERRORTYPES
	*If error type is used test that it is only one word and that word is an allowed error type
	if "`errortype'" != "" {
		local errortype = lower("`errortype'")
		if (`: word count `errortype'' != 1) | !inlist("`errortype'", "sd", "se", "errhide") {
			noi di as error "Value in option errortype(`errortype') can only one out of the following words; se, sd, errhide."
			error 198
		}
	}
	else {
		*No errortype specified use default which is standard errors
		local errortype "se"
	}

	*DEFAULT STAR LEVELS
	*Default star levels if option not used
	if "`starlevels'" == "" local starlevels ".1 .05 .01"

	/*************

		Initiate the result matrix

	*************/

	*Creates the template for the result matrix in a subfunction
	templateResultMatrix
	mat startRow = r(startRow)
	local colnames = "`r(colnames)'"

	*Remove this when ready for production
	//noi di "Start row to see headers, remove for production"
	//matlist startRow // See the default row with its column names

	*Initiate the result matrix with a place holder row that will not be used for anything. Matrices cannot be initiated empty
	mat ddtab_resultMap = startRow
	mat rownames ddtab_resultMap = placeholder

	/*************

		Loop over all variables and prepare the data

	*************/

	foreach var of local varlist {

		//noi di "Variable `var'"

		*Each variable is a row in the result matrix
		mat `var' = startRow
		mat rownames `var' = `var'
		mat colnames `var' = `colnames'

		*Local that keeps track of which column to fill
		local colindex 0

		tempvar regsample

		/*************

			Calculating 2nd difference and restict the sample
			for this output var

		*************/

		*Run the regression to get the double difference
		qui reg `var' `tmt'#`t' `covariates'
		mat resTable = r(table)

		//noi di "Rest table 2nd diff: reg `var' `tmt'#`t' `covariates'"
		//matlist resTable

		**This is why this is done first. All other calculations
		* for this outcome var should be restricted to this sample.
		gen `regsample' = e(sample)
		local N `e(N)'

		**Test that the dummy vars creates for valid groups for each
		* combination of time and treat in the sample used for this outcome var
		testDDdums `t' `tmt' `regsample' `var'  //comment in when this is made into a command

		*Get the second differnce
		local ++colindex
		mat `var'[1,`colindex'] =  el(resTable,1,4)

		*Get the standard error of second difference
		local ++colindex
		convertErrs el(resTable,2,4) `N' "`errortype'"
		mat `var'[1,`colindex'] =  `r(converted_error)'

		*Get the number of stars using sub-command countStars
		local ++colindex
		local pvalue = el(resTable,4,4)
		countStars `pvalue' `starlevels'
		mat `var'[1,`colindex'] = `r(stars)'

		*Get the N of second difference regression
		local ++colindex
		mat `var'[1,`colindex'] = `N'

		/*************

			Calculating 1st differences

		*************/
		forvalues tmt01 = 0/1 {

			*Regress time against the outcome var one tmt group at the time
			qui reg `var' `t' `covariates' if `tmt' == `tmt01' & `regsample' == 1
			mat resTable = r(table)

			//noi di "Rest table 1st diff: reg `var' `t' `covariates' if `tmt' == `tmt01' & `regsample' == 1"
			//matlist resTable

			//Get the 1st diff
			local ++colindex
			mat `var'[1,`colindex'] =  el(resTable,1,1)

			*Get the standard error of 1st diff
			local ++colindex
			convertErrs el(resTable,2,1) `e(N)' "`errortype'"
			mat `var'[1,`colindex'] =  `r(converted_error)'

			*Get the number of stars using sub-command countStars
			local ++colindex
			local pvalue = el(resTable,4,4)
			countStars `pvalue' `starlevels'
			mat `var'[1,`colindex'] = `r(stars)'

			*Get the N of first difference regression
			local ++colindex
			mat `var'[1,`colindex'] =  `e(N)'

		}

		/*************

			Calculating standard means for all groups

		*************/
		forvalues tmt01 = 0/1 {
			forvalues t01 = 0/1 {

				*Summary stats on this group
				qui mean `var' if `tmt' == `t01' & `t' == `tmt01' & `regsample' == 1

				mat resTable = r(table)

				//Get the mean
				local ++colindex
				mat `var'[1,`colindex'] =  el(resTable,1,1)

				*Get the standard error of the mean
				local ++colindex
				convertErrs el(resTable,2,1)  `e(N)' "`errortype'"
				mat `var'[1,`colindex'] =  `r(converted_error)'

				*Get the N of the ordinary means regressions
				local ++colindex
				mat `var'[1,`colindex'] =  `e(N)'
			}
		}

		*Append this row to the result table
		mat 	ddtab_resultMap = (ddtab_resultMap \ `var')

	}

	*Remove placeholder row
	matrix ddtab_resultMap = ddtab_resultMap[2..., 1...]

	*Show the final matrix will all data needed to start building the output
	//noi di "Matlist with results"
	//matlist ddtab_resultMap

	/*************

		Output table in result window

	*************/

	outputwindow `varlist' , ddtab_resultMap(ddtab_resultMap) labmaxlen(`labmaxlen') rwlbls(`rowlabels') ///
		starlevels("`starlevels'") covariates(`covariates') `errortype'

	/*************

		Output table in LaTeX

	*************/

	if "`savetex'" != "" {

		//outputtex `varlist' , ddtab_resultMap(ddtab_resultMap) savetex(`savetex')

	}

end

/***************************************
****************************************

	Write sub-commands for input handling

****************************************
***************************************/

**Program to prepare row labels for each outcome var, using variable name,
* variable label or manually entered labels depedning on user input. Variable
* names are used if no input.
cap program drop 	prepRowLabels
	program define	prepRowLabels, rclass

	syntax varlist, [rowlabtype(string) rowlabtext(string)]

	*First test input
	if "`rowlabtype'" == "varlab" | "`rowlabtype'" == "" | "`rowlabtype'" == "varname" {
		//All is good do nothing
	}
	else {
		noi display as error "{phang}Row label type [`rowlabtype'] is not a valid row label type. Enter either {it:varlab} or {it:varname} (the default if not specified is {it:varname}). See option {help ieddtable:rowlabtype} for details."
		error 198
	}

	/*************
		Parse through the manually entered labels
	*************/

	*Create a local with the rowlabel input to be tokenized
	local row_labels_to_tokenize `rowlabtext'

	while "`row_labels_to_tokenize'" != "" {

		*Parsing name and label pair
		gettoken nameAndLabel row_labels_to_tokenize : row_labels_to_tokenize, parse("@@")

		*Splitting name and label
		gettoken name label : nameAndLabel

		/*
			We store two locals, one with varnames and one with label. They are
			stored in the same order, so if we find varname we know we will find
			the corresponding label in the same order in the other local.
		*/

		*** Tests

		*Checking that the variables used in rowlabels() are included in the table
		local name_correct : list name in varlist
		if `name_correct' == 0 {
			noi display as error "{phang}Variable [`name'] listed in rowlabtext(`rowlabtext') is not found among the outcome variables."
			error 111
		}

		*Testing that no label is missing
		if "`label'" == "" {
			noi display as error "{phang}For variable [`name'] listed in rowlabtext(`rowlabels') you have not specified any label. Labels are requried for all variables listed in rowlabels(). Variables omitted from rowlabtext() will be assigned labels according to the rule in rowlabtype(). See also option {help ieddtable:rowlabtext}"
			error 198
		}

		*Storing the name in local to be used to get index of corresponding label in the second local
		local rowLabelNames `"`rowLabelNames' "`name'" "'

		*Removing leading or trailing spaces and store label with the same index as in the name local above
		local label = trim("`label'")
		local rowLabelLabels `"`rowLabelLabels' "`label'" "'

		*Parse char is not removed by gettoken, so remove it and start over
		local row_labels_to_tokenize = subinstr("`row_labels_to_tokenize'" ,"@@","",1)
	}

	**Set up locals to be returned. One with row labels without varname but in
	* final order, and one local with length of longest label
	local preppedRowLabels
	local maxLen 0

	*Loop over all varaibles and prepare the labels
	foreach var of local varlist {

		**Get the index of this variable in manually entered labels. Index is
		* zero if no manually entered label for this variable
		local rowLabPos : list posof "`var'" in rowLabelNames

		if `rowLabPos' == 0 {

			*No label was manually entered for this variable, use the other rules
			if "`rowlabtype'" == "varlab" {
				local this_label : variable label `var'		//Use variable label
			}
			else {

				local this_label `var'						//Default, use varname

			}
		}
		else {
			*Getting the manually defined label corresponding to this variable
			local this_label : word `rowLabPos' of `rowLabelLabels'
		}

		*Update the two locals that will be returned
		local preppedRowLabels "`preppedRowLabels' @@`this_label'"	//Prepare the final list
		local maxLen = max(strlen("`this_label'"),`maxLen')	//Store the length on the longest label, used on some outputs
	}

	*Return the locals
	return local rowlabels `preppedRowLabels'
	return local rowlabel_maxlen `maxLen'

end

** Program that test the t and tmt variables are valid dummies
*  for a Diff-in-Diff. I.e. they are both dummies and there are
*  at least 2 observations in each combination (0,0), (1,0),
*  (0,1) and (1,1)
cap program drop 	testDDdums
	program define	testDDdums

		args time treat samplevar outputvar

		*Test taht the dummies are dummies
		foreach dummy in `time' `treat' {

			cap assert inlist(`dummy',1,0) | missing(`dummy') | `samplevar' == 0
			if _rc {
				noi di as error "{phang}In the difference in differnce regression for outputvar [`outputvar'], the dummy [`dummy'] is not a real dummy as it has values differnt from 1 and 0. See tab below. The tab is restricted to the observations that are not excluded due to missing values etc. in the difference in differnce regression.{p_end}""
				noi tab `dummy' if `samplevar' == 1, missing
				error 480
			}
		}

		**Test that for only two of three dummies there are observations
		* that has only that dummy. I.e. the two that is not the
		* interaction. If the interaction is 1, all three shluld be 1.

		*Test that there is some observations in each group
		forvalues tmt01 = 0/1 {
			forvalues t01 = 0/1 {

				*Summary stats on this group
				qui count if `treat' == `t01' & `time' == `tmt01' & `samplevar' == 1

				//There got to be more than 1 observation in each group for the regression to make sense
				if `r(N)' < 2 {
					noi di as error "{phang}In the difference in differnce regression for outputvar [`outputvar'] there were not enough observations in each combination of treatment [`treat'] and time [`time']. The tab below is restricted to the observations that are not excluded due to missing values etc. in the difference in differnce regression.{p_end}""
					noi tab `treat' `time' if `samplevar' == 1, missing
					error 480

				}
			}
		}

	end

/***************************************
****************************************

	Write sub-commands for stats

****************************************
***************************************/

*Sets up template for the result matrix
cap program drop 	templateResultMatrix
	program define	templateResultMatrix, rclass

	*Set the names of the different columns in the result Matrix
	local 2ndDiff_cols 			2D 2D_err 2D_stars 2D_N

	local 1stDiff_C_cols		1DC 1DC_err 1DC_stars 1DC_N
	local 1stDiff_T_cols		1DT 1DT_err 1DT_stars 1DT_N

	local basicMean_C0_cols		C0_mean C0_err C0_N
	local basicMean_T0_cols		T0_mean T0_err T0_N
	local basicMean_C1_cols		C1_mean C1_err C1_N
	local basicMean_T1_cols		T1_mean T1_err T1_N

	local colnames `2ndDiff_cols' `1stDiff_C_cols' `1stDiff_T_cols' `basicMean_C0_cols' `basicMean_T0_cols' `basicMean_C1_cols' `basicMean_T0_cols'

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

	return matrix startRow startRow
	return local colnames `colnames'

end

*Take the significance levels and count number of starts
cap program drop 	countStars
	program define	countStars, rclass

	args pvalue star1 star2 star3

	local stars 0
	foreach star_p_level in `star1' `star2' `star3' {

		if `pvalue' < `star_p_level' local ++stars
	}

	return local stars `stars'

end

**Convert the errors to the display stats picked
* by the user. Standard errors is the default.
cap program drop 	convertErrs
	program define	convertErrs, rclass

	args se_err N errortype

	*Test if custom star levels are used
	if "`errortype'" == "sd" {
		local err = `se_err' * sqrt(`N')
	}
	else {
		//For se keep se, for errhide keep se as matrix must have some value even if it will not be used
		local err = `se_err'
	}

	return local converted_error `err'

end

/***************************************
****************************************

	Write sub-commands for outputs

****************************************
***************************************/

	******
	*Then the result matrix can be passed into subcommands that output in either Excel, LaTeX or in the main window.

	*The results can be accessed like this, which makes the sub-commands less sensitive to changing column order in the section above.
	//mat A = ddtab_resultMap[3, "C0_Mean"] // returns a 1x1 matrix with the baseline mean for the countrol grop for the thrid outcome var
	//local a = el(A,1,1)				// returns the value

	//matlist A
	//di `a'

	/*
		Column name dictionary
			Differences:
			- 2D : Second differnce coefficient (t*tmt == 1)
			- 1DC : First  differnce coefficient control (t == 0)
			- 1DT : First  differnce coefficient treatment (tmt == 0)

			for each coefficent these stats are also provided:
				- _err : Second differnce errors (type of errors is set in command errortype)
				- _stars :  Second Differene - The number of significance stars (sig level set in command)
				- _N : Second Difference - Number of observtions in the regression

			Group means:
			- C0 - Control time 0
			- T0 - Treatment time 0
			- C1 - Control time 1
			- T1 - Treatment time 1

			for each group these stats are also provided:
				- _mean : the mean of the group
				- _err : the error in the mean (type of errors is set in command errortype)
				- _N : number of observations in baseline means

	*/

	/*************

		Output table in result window

	*************/

	cap program drop 	outputwindow
		program define	outputwindow

		/*
		Todo:
			Add N somewhere
			Make format specifiable by user

		*/

		syntax varlist , ddtab_resultMap(name) labmaxlen(numlist) rwlbls(string) starlevels(string) [covariates(string) errhide sd se]

		*Prepare lables for the erorrs to be displayed (in case any)
		if "`sd'" != "" local errlabel "SD"
		if "`se'" != "" local errlabel "SE"

		*Count numbers of variables to loop over
		local numVars = `:word count `varlist''

		*List of variabls to display and loop over when formatting
		local statlist 2D 1DT 1DC C0_mean T0_mean 2D_err 1DT_err 1DC_err C0_err T0_err 2D_N 1DT_N 1DC_N C0_N T0_N
		local diformat = "%9.2f"

		*************************
		* Table width for label column

		local first_hhline = 2 + `labmaxlen'
		local first_col = 4 + `labmaxlen'

		*************************
		* Table width for basline columns

		local bsln_space = 2
		local bsln_stat_left = `bsln_space' + 1
		local bsln_width = ((`bsln_space' * 2) + 8)

		*************************
		* Table width for first difference column

		local diff_space = 3
		local diff_stat_left = `diff_space' + 1
		local diff_width = ((`diff_space' * 2) + 10)

		*************************
		* Table width control column

		local ctrl_hline = `bsln_width' + 1 + `diff_width'
		local ctrl_space = (`ctrl_hline' - 7) / 2

		*************************
		* Table width treatment column

		local tmt_hline = `bsln_width' + 1 + `diff_width'
		local tmt_space = (`tmt_hline' - 9) / 2

		*************************
		* Table width diff diff column

		local didi_stat_left = 4
		local diffdiff_width  = 17

		*************************
		* Calculate stats column indexes

		local bsln_c_col	= `first_col'  + `bsln_width' + 1
		local diff_c_col	= `bsln_c_col' + `diff_width' + 1
		local bsln_t_col	= `diff_c_col' + `bsln_width' + 1
		local diff_t_col	= `bsln_t_col' + `diff_width' + 1
		local didi_col		= `diff_t_col' + `diffdiff_width' + 1

		*************************
		* Start writing table

		noi di as text "{c TLC}{hline `first_hhline'}{c TT}{hline `ctrl_hline'}{c TT}{hline `tmt_hline'}{c TT}{hline 17}{c TRC}"
		noi di as text "{c |}{col `first_col'}{c |}{dup `ctrl_space': }Control{dup `ctrl_space': }{c |}{dup `tmt_space': }Treatment{dup `tmt_space': }{c |}  Difference-in  {c |}"
		noi di as text "{c |}{col `first_col'}{c |}{dup `bsln_space': }Baseline{dup `bsln_space': }{c |}{dup `diff_space': }Difference{dup `diff_space': }{c |}{dup `bsln_space': }Baseline{dup `bsln_space': }{c |}{dup `diff_space': }Difference{dup `diff_space': }{c |}   -difference   {c |}"

		*Stat lable row different if errors are shown or not
		noi di as text "{c |}{col `first_col'}{c |}{dup `bsln_stat_left': } Mean{col `bsln_c_col'}{c |}{dup `diff_stat_left': } Coef{col `diff_c_col'}{c |}{dup `bsln_stat_left': } Mean{col `bsln_t_col'}{c |}{dup `diff_stat_left': } Coef{col `diff_t_col'}{c |}{dup `didi_stat_left': } Coef{col `didi_col'}{c |}"
		if "`errhide'" == "" {
			noi di as text "{c |}{col `first_col'}{c |}{dup `bsln_stat_left': }(`errlabel'){col `bsln_c_col'}{c |}{dup `diff_stat_left': }(`errlabel'){col `diff_c_col'}{c |}{dup `bsln_stat_left': }(`errlabel'){col `bsln_t_col'}{c |}{dup `diff_stat_left': }(`errlabel'){col `diff_t_col'}{c |}{dup `didi_stat_left': }(`errlabel'){col `didi_col'}{c |}"
		}
		noi di as text "{c |}{col 3}Variable{col `first_col'}{c |}{dup `bsln_stat_left': } N{col `bsln_c_col'}{c |}{dup `diff_stat_left': } N{col `diff_c_col'}{c |}{dup `bsln_stat_left': } N{col `bsln_t_col'}{c |}{dup `diff_stat_left': } N{col `diff_t_col'}{c |}{dup `didi_stat_left': } N{col `didi_col'}{c |}"

		*Bottom row to table header
		noi di as text "{c LT}{hline `first_hhline'}{c +}{hline `bsln_width'}{c +}{hline `diff_width'}{c +}{hline `bsln_width'}{c +}{hline `diff_width'}{c +}{hline 17}{c RT}"

		*Loop over each variable and prepare the row
		forvalues row = 1/`numVars' {

			*Get lables from the list of lables previosly prepared
			local rwlbls = trim(subinstr("`rwlbls'", "@@","", 1))
			gettoken label rwlbls : rwlbls, parse("@@")

			*Loop over all the stats for this variable
			foreach stat of local statlist {

				**Run sub command that gets value from matrix and prepares it
				* in the format suitable for the result window table (and adding
				* stars if applicable)
				displayformatter , statname("`stat'") row(`row') ddtab_resultMap(ddtab_resultMap) diformat("`diformat'") bslnw(`bsln_width') diffw(`diff_width') ddw(`diffdiff_width')

				*The main stat
				local `stat' `r(disp_stata)'

				*The number of spaces before the stat in the colum
				local `stat'_space = `r(disp_pre_space)'
			}

			*Disaplay each variable row at the same time
			noi di as text "{c |} `label'{col `first_col'}{c |}{dup `C0_mean_space': }`C0_mean'{dup `1DC_space': }`1DC'{dup `T0_mean_space': }`T0_mean'{dup `1DT_space': }`1DT'{dup `2D_space': }`2D'"

			*Unless error type is errhide, show the errors on a seperate row
			if "`errhide'" == "" {
				noi di as text "{c |}{col `first_col'}{c |}{dup `C0_err_space': }`C0_err'{dup `1DC_err_space': }`1DC_err'{dup `T0_err_space': }`T0_err'{dup `1DT_err_space': }`1DT_err'{dup `2D_err_space': }`2D_err'"
			}

			noi di as text "{c |}{col `first_col'}{c |}{dup `C0_N_space': }`C0_N'{dup `1DC_N_space': }`1DC_N'{dup `T0_N_space': }`T0_N'{dup `1DT_N_space': }`1DT_N'{dup `2D_N_space': }`2D_N'"

		}

		*Add bottom notes to the table
		noi di as text "{c BLC}{hline `first_hhline'}{c BT}{hline `bsln_width'}{c BT}{hline `diff_width'}{c BT}{hline `bsln_width'}{c BT}{hline `diff_width'}{c BT}{hline 17}{c BRC}"

		*************************
		* Write notes below the table

		*Show stars levels
		local star1_value : word 1 of `starlevels'
		local star2_value : word 2 of `starlevels'
		local star3_value : word 3 of `starlevels'

		noi di as text "  ***, **, and * indicate significance at the `star3_value', `star2_value', and `star1_value' percent critical level. "

		*List covariates used
		if ("`covariates'" != "") {
			noi di as text "  The following variables was included as covariates [`covariates']"
		}

	end

cap program drop 	displayformatter
	program define	displayformatter, rclass

	syntax , statname(string) row(numlist) ddtab_resultMap(name) diformat(string)  bslnw(numlist) diffw(numlist) ddw(numlist)

		local numSpace 0

		mat temp = ddtab_resultMap[`row', "`statname'"]
		local `statname' = el(temp,1,1)

		if substr("`statname'", -2,.) == "_N" {
			local `statname'	: display %9.0f ``statname''
		}
		else {
			local `statname' 	: display `diformat' ``statname''
		}

		*Trime spaces on left from left.
		local `statname' = ltrim("``statname''")

		*For coefficients, add stars if applicable
		if inlist("`statname'", "2D", "1DT", "1DC") {

			mat starNumMat = ddtab_resultMap[`row', "`statname'_stars"]
			local starNum = el(starNumMat,1,1)

			if `starNum' == 0 local `statname' "``statname''    "
			if `starNum' == 1 local `statname' "``statname''*   "
			if `starNum' == 2 local `statname' "``statname''**  "
			if `starNum' == 3 local `statname' "``statname''*** "
		}

		*Add brackets to errors
		if inlist("`statname'", "2D_err", "1DT_err", "1DC_err", "C0_err", "T0_err") {
			local `statname' "(``statname'')"
		}

		*Get the lengt of the characters to display
		local len = strlen("``statname''")

		*Which column for this stat
		local colName = substr("`statname'", 1, 2)

		*Get corresponding width for that col
		if "`colName'" == "C0" local colw = `bslnw'
		if "`colName'" == "T0" local colw = `bslnw'
		if "`colName'" == "1D" local colw = `diffw'
		if "`colName'" == "2D" local colw = `ddw'

		* Calculate the number of spaces needed bofore
		* the value and add spaces after it
		if inlist("`statname'", "C0_mean", "T0_mean", "C0_N", "T0_N") {
			*Baseline mean values
			return local disp_stata "``statname''  {c |}"
			local numSpace = `colw' - `len' - 2
		}
		else if inlist("`statname'", "C0_err", "T0_err") {
			*Baseline mean values errors
			return local disp_stata "``statname'' {c |}"
			local numSpace = `colw' - `len' - 1
		}
		else if inlist("`statname'", "1DT", "1DC", "2D") {
			*First difference coefficent
			return local disp_stata "``statname''{c |}"
			local numSpace = `colw' - `len'
		}
		else if inlist("`statname'", "1DT_N", "1DC_N", "2D_N") {
			*First difference coefficent
			return local disp_stata "``statname''    {c |}"
			local numSpace = `colw' - `len' - 4
		}
		else if inlist("`statname'", "1DT_err", "1DC_err", "2D_err")  {
			*First difference coefficient error
			return local disp_stata "``statname''   {c |}"
			local numSpace = `colw' - `len' - 3
		}

		**If numbers are so big that numSapce is negative, set it to 0 as
		* numSpace cannot be negative. Table will show incorrectly but
		* will display.
		if `numSpace' < 0 local numSpace 0

		return local disp_pre_space = `numSpace'
		return local disp_len = `len'

	end

cap program drop 	ieddtable
	program define	ieddtable

	syntax varlist, ///
					///
		t(varname numeric) tmt(varname numeric) 			///
		[ 													///
		COVARiates(varlist numeric)							///
		STARLevels(numlist descending min=3 max=3 >0 <1)	///
		STARSNOadd											///
		firstdiff											///
		rowlabtype(string) 									///
		rowlabtext(string)									///
		errortype(string)									///
		]

	/*************

		Input handling

	*************/

	*LABELS
	*Test and prepare the row lables and test how long the longest label is.
	prepRowLabels `varlist', rowlabtype("`rowlabtype'") rowlabtext("`rowlabtext'")
	local rowlabels "`r(rowlabels)'"
	local labmaxlen "`r(rowlabel_maxlen)'"

	*ERRORTYPES
	*If error type is used test that it is only one word and that word is an allowed error type
	if "`errortype'" != "" {
		local errortype = lower("`errortype'")
		if (`: word count `errortype'' != 1) | !inlist("`errortype'", "sd", "se", "errhide") {
			noi di as error "Value in option errortype(`errortype') can only one out of the following words; se, sd, errhide."
			error 198
		}
	}
	else {
		*No errortype specified use default which is standard errors
		local errortype "se"
	}

	*DEFAULT STAR LEVELS
	*Default star levels if option not used
	if "`starlevels'" == "" local starlevels ".1 .05 .01"

	/*************

		Initiate the result matrix

	*************/

	*Creates the template for the result matrix in a subfunction
	templateResultMatrix
	mat startRow = r(startRow)
	local colnames = "`r(colnames)'"

	*Remove this when ready for production
	//noi di "Start row to see headers, remove for production"
	//matlist startRow // See the default row with its column names

	*Initiate the result matrix with a place holder row that will not be used for anything. Matrices cannot be initiated empty
	mat ddtab_resultMap = startRow
	mat rownames ddtab_resultMap = placeholder

	/*************

		Loop over all variables and prepare the data

	*************/

	foreach var of local varlist {

		//noi di "Variable `var'"

		*Each variable is a row in the result matrix
		mat `var' = startRow
		mat rownames `var' = `var'
		mat colnames `var' = `colnames'

		*Local that keeps track of which column to fill
		local colindex 0

		tempvar regsample

		/*************

			Calculating 2nd difference and restict the sample
			for this output var

		*************/

		*Run the regression to get the double difference
		qui reg `var' `tmt'#`t' `covariates'
		mat resTable = r(table)

		//noi di "Rest table 2nd diff: reg `var' `tmt'#`t' `covariates'"
		//matlist resTable

		**This is why this is done first. All other calculations
		* for this outcome var should be restricted to this sample.
		gen `regsample' = e(sample)
		local N `e(N)'

		**Test that the dummy vars creates for valid groups for each
		* combination of time and treat in the sample used for this outcome var
		testDDdums `t' `tmt' `regsample' `var'  //comment in when this is made into a command

		*Get the second differnce
		local ++colindex
		mat `var'[1,`colindex'] =  el(resTable,1,4)

		*Get the standard error of second difference
		local ++colindex
		convertErrs el(resTable,2,4) `N' "`errortype'"
		mat `var'[1,`colindex'] =  `r(converted_error)'

		*Get the number of stars using sub-command countStars
		local ++colindex
		local pvalue = el(resTable,4,4)
		countStars `pvalue' `starlevels'
		mat `var'[1,`colindex'] = `r(stars)'

		*Get the N of second difference regression
		local ++colindex
		mat `var'[1,`colindex'] = `N'

		/*************

			Calculating 1st differences

		*************/
		forvalues tmt01 = 0/1 {

			*Regress time against the outcome var one tmt group at the time
			qui reg `var' `t' `covariates' if `tmt' == `tmt01' & `regsample' == 1
			mat resTable = r(table)

			//noi di "Rest table 1st diff: reg `var' `t' `covariates' if `tmt' == `tmt01' & `regsample' == 1"
			//matlist resTable

			//Get the 1st diff
			local ++colindex
			mat `var'[1,`colindex'] =  el(resTable,1,1)

			*Get the standard error of 1st diff
			local ++colindex
			convertErrs el(resTable,2,1) `e(N)' "`errortype'"
			mat `var'[1,`colindex'] =  `r(converted_error)'

			*Get the number of stars using sub-command countStars
			local ++colindex
			local pvalue = el(resTable,4,4)
			countStars `pvalue' `starlevels'
			mat `var'[1,`colindex'] = `r(stars)'

			*Get the N of first difference regression
			local ++colindex
			mat `var'[1,`colindex'] =  `e(N)'

		}

		/*************

			Calculating standard means for all groups

		*************/
		forvalues tmt01 = 0/1 {
			forvalues t01 = 0/1 {

				*Summary stats on this group
				qui mean `var' if `tmt' == `t01' & `t' == `tmt01' & `regsample' == 1

				mat resTable = r(table)

				//Get the mean
				local ++colindex
				mat `var'[1,`colindex'] =  el(resTable,1,1)

				*Get the standard error of the mean
				local ++colindex
				convertErrs el(resTable,2,1)  `e(N)' "`errortype'"
				mat `var'[1,`colindex'] =  `r(converted_error)'

				*Get the N of the ordinary means regressions
				local ++colindex
				mat `var'[1,`colindex'] =  `e(N)'
			}
		}

		*Append this row to the result table
		mat 	ddtab_resultMap = (ddtab_resultMap \ `var')

	}

	*Remove placeholder row
	matrix ddtab_resultMap = ddtab_resultMap[2..., 1...]

	*Show the final matrix will all data needed to start building the output
	//noi di "Matlist with results"
	//matlist ddtab_resultMap

	/*************

		Output table in result window

	*************/

	outputwindow `varlist' , ddtab_resultMap(ddtab_resultMap) labmaxlen(`labmaxlen') rwlbls(`rowlabels') ///
		starlevels("`starlevels'") covariates(`covariates') `errortype'

	/*************

		Output table in LaTeX

	*************/

	if "`savetex'" != "" {

		//outputtex `varlist' , ddtab_resultMap(ddtab_resultMap) savetex(`savetex')

	}

end

/***************************************
****************************************

	Write sub-commands for input handling

****************************************
***************************************/

**Program to prepare row labels for each outcome var, using variable name,
* variable label or manually entered labels depedning on user input. Variable
* names are used if no input.
cap program drop 	prepRowLabels
	program define	prepRowLabels, rclass

	syntax varlist, [rowlabtype(string) rowlabtext(string)]

	*First test input
	if "`rowlabtype'" == "varlab" | "`rowlabtype'" == "" | "`rowlabtype'" == "varname" {
		//All is good do nothing
	}
	else {
		noi display as error "{phang}Row label type [`rowlabtype'] is not a valid row label type. Enter either {it:varlab} or {it:varname} (the default if not specified is {it:varname}). See option {help ieddtable:rowlabtype} for details."
		error 198
	}

	/*************
		Parse through the manually entered labels
	*************/

	*Create a local with the rowlabel input to be tokenized
	local row_labels_to_tokenize `rowlabtext'

	while "`row_labels_to_tokenize'" != "" {

		*Parsing name and label pair
		gettoken nameAndLabel row_labels_to_tokenize : row_labels_to_tokenize, parse("@@")

		*Splitting name and label
		gettoken name label : nameAndLabel

		/*
			We store two locals, one with varnames and one with label. They are
			stored in the same order, so if we find varname we know we will find
			the corresponding label in the same order in the other local.
		*/

		*** Tests

		*Checking that the variables used in rowlabels() are included in the table
		local name_correct : list name in varlist
		if `name_correct' == 0 {
			noi display as error "{phang}Variable [`name'] listed in rowlabtext(`rowlabtext') is not found among the outcome variables."
			error 111
		}

		*Testing that no label is missing
		if "`label'" == "" {
			noi display as error "{phang}For variable [`name'] listed in rowlabtext(`rowlabels') you have not specified any label. Labels are requried for all variables listed in rowlabels(). Variables omitted from rowlabtext() will be assigned labels according to the rule in rowlabtype(). See also option {help ieddtable:rowlabtext}"
			error 198
		}

		*Storing the name in local to be used to get index of corresponding label in the second local
		local rowLabelNames `"`rowLabelNames' "`name'" "'

		*Removing leading or trailing spaces and store label with the same index as in the name local above
		local label = trim("`label'")
		local rowLabelLabels `"`rowLabelLabels' "`label'" "'

		*Parse char is not removed by gettoken, so remove it and start over
		local row_labels_to_tokenize = subinstr("`row_labels_to_tokenize'" ,"@@","",1)
	}

	**Set up locals to be returned. One with row labels without varname but in
	* final order, and one local with length of longest label
	local preppedRowLabels
	local maxLen 0

	*Loop over all varaibles and prepare the labels
	foreach var of local varlist {

		**Get the index of this variable in manually entered labels. Index is
		* zero if no manually entered label for this variable
		local rowLabPos : list posof "`var'" in rowLabelNames

		if `rowLabPos' == 0 {

			*No label was manually entered for this variable, use the other rules
			if "`rowlabtype'" == "varlab" {
				local this_label : variable label `var'		//Use variable label
			}
			else {

				local this_label `var'						//Default, use varname

			}
		}
		else {
			*Getting the manually defined label corresponding to this variable
			local this_label : word `rowLabPos' of `rowLabelLabels'
		}

		*Update the two locals that will be returned
		local preppedRowLabels "`preppedRowLabels' @@`this_label'"	//Prepare the final list
		local maxLen = max(strlen("`this_label'"),`maxLen')	//Store the length on the longest label, used on some outputs
	}

	*Return the locals
	return local rowlabels `preppedRowLabels'
	return local rowlabel_maxlen `maxLen'

end

** Program that test the t and tmt variables are valid dummies
*  for a Diff-in-Diff. I.e. they are both dummies and there are
*  at least 2 observations in each combination (0,0), (1,0),
*  (0,1) and (1,1)
cap program drop 	testDDdums
	program define	testDDdums

		args time treat samplevar outputvar

		*Test taht the dummies are dummies
		foreach dummy in `time' `treat' {

			cap assert inlist(`dummy',1,0) | missing(`dummy') | `samplevar' == 0
			if _rc {
				noi di as error "{phang}In the difference in differnce regression for outputvar [`outputvar'], the dummy [`dummy'] is not a real dummy as it has values differnt from 1 and 0. See tab below. The tab is restricted to the observations that are not excluded due to missing values etc. in the difference in differnce regression.{p_end}""
				noi tab `dummy' if `samplevar' == 1, missing
				error 480
			}
		}

		**Test that for only two of three dummies there are observations
		* that has only that dummy. I.e. the two that is not the
		* interaction. If the interaction is 1, all three shluld be 1.

		*Test that there is some observations in each group
		forvalues tmt01 = 0/1 {
			forvalues t01 = 0/1 {

				*Summary stats on this group
				qui count if `treat' == `t01' & `time' == `tmt01' & `samplevar' == 1

				//There got to be more than 1 observation in each group for the regression to make sense
				if `r(N)' < 2 {
					noi di as error "{phang}In the difference in differnce regression for outputvar [`outputvar'] there were not enough observations in each combination of treatment [`treat'] and time [`time']. The tab below is restricted to the observations that are not excluded due to missing values etc. in the difference in differnce regression.{p_end}""
					noi tab `treat' `time' if `samplevar' == 1, missing
					error 480

				}
			}
		}

	end

/***************************************
****************************************

	Write sub-commands for stats

****************************************
***************************************/

*Sets up template for the result matrix
cap program drop 	templateResultMatrix
	program define	templateResultMatrix, rclass

	*Set the names of the different columns in the result Matrix
	local 2ndDiff_cols 			2D 2D_err 2D_stars 2D_N

	local 1stDiff_C_cols		1DC 1DC_err 1DC_stars 1DC_N
	local 1stDiff_T_cols		1DT 1DT_err 1DT_stars 1DT_N

	local basicMean_C0_cols		C0_mean C0_err C0_N
	local basicMean_T0_cols		T0_mean T0_err T0_N
	local basicMean_C1_cols		C1_mean C1_err C1_N
	local basicMean_T1_cols		T1_mean T1_err T1_N

	local colnames `2ndDiff_cols' `1stDiff_C_cols' `1stDiff_T_cols' `basicMean_C0_cols' `basicMean_T0_cols' `basicMean_C1_cols' `basicMean_T0_cols'

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

	return matrix startRow startRow
	return local colnames `colnames'

end

*Take the significance levels and count number of starts
cap program drop 	countStars
	program define	countStars, rclass

	args pvalue star1 star2 star3

	local stars 0
	foreach star_p_level in `star1' `star2' `star3' {

		if `pvalue' < `star_p_level' local ++stars
	}

	return local stars `stars'

end

**Convert the errors to the display stats picked
* by the user. Standard errors is the default.
cap program drop 	convertErrs
	program define	convertErrs, rclass

	args se_err N errortype

	*Test if custom star levels are used
	if "`errortype'" == "sd" {
		local err = `se_err' * sqrt(`N')
	}
	else {
		//For se keep se, for errhide keep se as matrix must have some value even if it will not be used
		local err = `se_err'
	}

	return local converted_error `err'

end

/***************************************
****************************************

	Write sub-commands for outputs

****************************************
***************************************/

	******
	*Then the result matrix can be passed into subcommands that output in either Excel, LaTeX or in the main window.

	*The results can be accessed like this, which makes the sub-commands less sensitive to changing column order in the section above.
	//mat A = ddtab_resultMap[3, "C0_Mean"] // returns a 1x1 matrix with the baseline mean for the countrol grop for the thrid outcome var
	//local a = el(A,1,1)				// returns the value

	//matlist A
	//di `a'

	/*
		Column name dictionary
			Differences:
			- 2D : Second differnce coefficient (t*tmt == 1)
			- 1DC : First  differnce coefficient control (t == 0)
			- 1DT : First  differnce coefficient treatment (tmt == 0)

			for each coefficent these stats are also provided:
				- _err : Second differnce errors (type of errors is set in command errortype)
				- _stars :  Second Differene - The number of significance stars (sig level set in command)
				- _N : Second Difference - Number of observtions in the regression

			Group means:
			- C0 - Control time 0
			- T0 - Treatment time 0
			- C1 - Control time 1
			- T1 - Treatment time 1

			for each group these stats are also provided:
				- _mean : the mean of the group
				- _err : the error in the mean (type of errors is set in command errortype)

	*/

	/*************

		Output table in result window

	*************/

	cap program drop 	outputwindow
		program define	outputwindow

		/*
		Todo:
			Add N somewhere
			Make format specifiable by user

		*/

		syntax varlist , ddtab_resultMap(name) labmaxlen(numlist) rwlbls(string) starlevels(string) [covariates(string) errhide sd se]

		*Prepare lables for the erorrs to be displayed (in case any)
		if "`sd'" != "" local errlabel "SD"
		if "`se'" != "" local errlabel "SE"

		*Count numbers of variables to loop over
		local numVars = `:word count `varlist''

		*List of variabls to display and loop over when formatting
		local statlist 2D 1DT 1DC C0_mean T0_mean 2D_err 1DT_err 1DC_err C0_err T0_err
		local diformat = "%9.2f"

		*************************
		* Table width for label column

		local first_hhline = 2 + `labmaxlen'
		local first_col = 4 + `labmaxlen'

		*************************
		* Table width for basline columns

		local bsln_space = 2
		local bsln_stat_right = `bsln_space' - 1
		local bsln_width = ((`bsln_space' * 2) + 8)

		*************************
		* Table width for first difference column

		local diff_space = 3
		local diff_width = ((`diff_space' * 2) + 10)

		*************************
		* Table width control column

		local ctrl_hline = `bsln_width' + 1 + `diff_width'
		local ctrl_space = (`ctrl_hline' - 7) / 2

		*************************
		* Table width treatment column

		local tmt_hline = `bsln_width' + 1 + `diff_width'
		local tmt_space = (`tmt_hline' - 9) / 2

		*************************
		* Table width diff diff column

		local diffdiff_width  = 17

		*************************
		* Start writing table

		noi di as text "{c TLC}{hline `first_hhline'}{c TT}{hline `ctrl_hline'}{c TT}{hline `tmt_hline'}{c TT}{hline 17}{c TRC}"
		noi di as text "{c |}{col `first_col'}{c |}{dup `ctrl_space': }Control{dup `ctrl_space': }{c |}{dup `tmt_space': }Treatment{dup `tmt_space': }{c |}  Difference-in  {c |}"
		noi di as text "{c |}{col 3}{col `first_col'}{c |}{dup `bsln_space': }Baseline{dup `bsln_space': }{c |}{dup `diff_space': }Difference{dup `diff_space': }{c |}{dup `bsln_space': }Baseline{dup `bsln_space': }{c |}{dup `diff_space': }Difference{dup `diff_space': }{c |}   -difference   {c |}"

		*Stat lable row different if errors are shown or not
		if "`errhide'" == "" {
			noi di as text "{c |}{col 3}Variable{col `first_col'}{c |}{dup `bsln_space': }Mean/(`errlabel'){dup `bsln_stat_right': }{c |}{dup `diff_space': }Coef/(`errlabel') {dup `diff_space': }{c |}{dup `bsln_space': }Mean/(`errlabel'){dup `bsln_stat_right': }{c |}{dup `diff_space': }Coef/(`errlabel') {dup `diff_space': }{c |}     Coef/(`errlabel')   {c |}"
		}
		else {
			noi di as text "{c |}{col 3}Variable{col `first_col'}{c |}{dup `bsln_space': }  Mean   {dup `bsln_stat_right': }{c |}{dup `diff_space': }   Coef   {dup `diff_space': }{c |}{dup `bsln_space': }  Mean   {dup `bsln_stat_right': }{c |}{dup `diff_space': }   Coef   {dup `diff_space': }{c |}       Coef      {c |}"
		}

		*Bottom row to table header
		noi di as text "{c LT}{hline `first_hhline'}{c +}{hline `bsln_width'}{c +}{hline `diff_width'}{c +}{hline `bsln_width'}{c +}{hline `diff_width'}{c +}{hline 17}{c RT}"

		*Loop over each variable and prepare the row
		forvalues row = 1/`numVars' {

			*Get lables from the list of lables previosly prepared
			local rwlbls = trim(subinstr("`rwlbls'", "@@","", 1))
			gettoken label rwlbls : rwlbls, parse("@@")

			*Loop over all the stats for this variable
			foreach stat of local statlist {

				**Run sub command that gets value from matrix and prepares it
				* in the format suitable for the result window table (and adding
				* stars if applicable)
				displayformatter , statname("`stat'") row(`row') ddtab_resultMap(ddtab_resultMap) diformat("`diformat'") bslnw(`bsln_width') diffw(`diff_width') ddw(`diffdiff_width')

				*The main stat
				local `stat' `r(disp_stata)'

				*The number of spaces before the stat in the colum
				local `stat'_space = `r(disp_pre_space)'
			}

			*Disaplay each variable row at the same time
			noi di as text "{c |} `label'{col `first_col'}{c |}{dup `C0_mean_space': }`C0_mean'{dup `1DC_space': }`1DC'{dup `T0_mean_space': }`T0_mean'{dup `1DT_space': }`1DT'{dup `2D_space': }`2D'"

			*Unless error type is errhide, show the errors on a seperate row
			if "`errhide'" == "" {
				noi di as text "{c |}{col `first_col'}{c |}{dup `C0_err_space': }`C0_err'{dup `1DC_err_space': }`1DC_err'{dup `T0_err_space': }`T0_err'{dup `1DT_err_space': }`1DT_err'{dup `2D_err_space': }`2D_err'"
			}

		}

		*Add bottom notes to the table
		noi di as text "{c BLC}{hline `first_hhline'}{c BT}{hline `bsln_width'}{c BT}{hline `diff_width'}{c BT}{hline `bsln_width'}{c BT}{hline `diff_width'}{c BT}{hline 17}{c BRC}"

		*************************
		* Write notes below the table

		*Show stars levels
		local star1_value : word 1 of `starlevels'
		local star2_value : word 2 of `starlevels'
		local star3_value : word 3 of `starlevels'

		noi di as text "  ***, **, and * indicate significance at the `star3_value', `star2_value', and `star1_value' percent critical level. "

		*List covariates used
		if ("`covariates'" != "") {
			noi di as text "  The following variables was included as covariates [`covariates']"
		}

	end

cap program drop 	displayformatter
	program define	displayformatter, rclass

	syntax , statname(string) row(numlist) ddtab_resultMap(name) diformat(string)  bslnw(numlist) diffw(numlist) ddw(numlist)

		local numSpace 0

		mat temp = ddtab_resultMap[`row', "`statname'"]
		local `statname' = el(temp,1,1)
		local `statname' 	: display `diformat' ``statname''

		*Trime spaces on left from left.
		local `statname' = ltrim("``statname''")

		*For coefficients, add stars if applicable
		if inlist("`statname'", "2D", "1DT", "1DC") {

			mat starNumMat = ddtab_resultMap[`row', "`statname'_stars"]
			local starNum = el(starNumMat,1,1)

			if `starNum' == 0 local `statname' "``statname''    "
			if `starNum' == 1 local `statname' "``statname''*   "
			if `starNum' == 2 local `statname' "``statname''**  "
			if `starNum' == 3 local `statname' "``statname''*** "
		}

		*Add brackets to errors
		if inlist("`statname'", "2D_err", "1DT_err", "1DC_err", "C0_err", "T0_err") {
			local `statname' "(``statname'')"
		}

		*Get the lengt of the characters to display
		local len = strlen("``statname''")

		*Which column for this stat
		local colName = substr("`statname'", 1, 2)

		*Get corresponding width for that col
		if "`colName'" == "C0" local colw = `bslnw'
		if "`colName'" == "T0" local colw = `bslnw'
		if "`colName'" == "1D" local colw = `diffw'
		if "`colName'" == "2D" local colw = `ddw'

		* Calculate the number of spaces needed bofore
		* the value and add spaces after it
		if inlist("`statname'", "C0_mean", "T0_mean") {
			*Baseline mean values
			return local disp_stata "``statname''  {c |}"
			local numSpace = `colw' - `len' - 2
		}
		else if inlist("`statname'", "C0_err", "T0_err") {
			*Baseline mean values errors
			return local disp_stata "``statname'' {c |}"
			local numSpace = `colw' - `len' - 1
		}
		else if inlist("`statname'", "1DT", "1DC", "2D") {
			*First difference coefficent
			return local disp_stata "``statname''{c |}"
			local numSpace = `colw' - `len'
		}
		else if inlist("`statname'", "1DT_err", "1DC_err", "2D_err")  {
			*First difference coefficient error
			return local disp_stata "``statname''   {c |}"
			local numSpace = `colw' - `len' - 3
		}

		**If numbers are so big that numSapce is negative, set it to 0 as
		* numSpace cannot be negative. Table will show incorrectly but
		* will display.
		if `numSpace' < 0 local numSpace 0

		return local disp_pre_space = `numSpace'
		return local disp_len = `len'

	end


[INFRA] - Added wave.do file

[INFRA] - Added 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 -expand -group FETCH -radix hexadecimal /top_tb/T1/stall_fetch
add wave -noupdate -expand -group FETCH -radix hexadecimal /top_tb/T1/instr_pc_reg_fetch
add wave -noupdate -expand -group FETCH -radix hexadecimal /top_tb/T1/curr_pc_pc_reg_fetch
add wave -noupdate -expand -group FETCH -radix hexadecimal /top_tb/T1/next_pc_fetch_iss
add wave -noupdate -expand -group FETCH -radix hexadecimal /top_tb/T1/next_seq_pc_pc_reg_fetch
add wave -noupdate -expand -group ISSUE -radix hexadecimal /top_tb/T1/valid_iss_ex
add wave -noupdate -expand -group ISSUE -radix hexadecimal /top_tb/T1/stall_iss
add wave -noupdate -expand -group ISSUE -radix hexadecimal /top_tb/T1/next_pc_iss_ex
add wave -noupdate -expand -group ISSUE -radix hexadecimal /top_tb/T1/next_beq_pc_iss_ex
add wave -noupdate -expand -group ISSUE -radix hexadecimal /top_tb/T1/next_beq_pc_carry_iss_ex
add wave -noupdate -expand -group ISSUE -radix hexadecimal /top_tb/T1/is_i_type_iss_ex
add wave -noupdate -expand -group ISSUE -radix hexadecimal /top_tb/T1/is_j_type_iss_ex
add wave -noupdate -expand -group ISSUE -radix hexadecimal /top_tb/T1/is_r_type_iss_ex
add wave -noupdate -expand -group ISSUE -radix hexadecimal /top_tb/T1/instr_iss_ex
add wave -noupdate -expand -group ISSUE -radix hexadecimal /top_tb/T1/op_iss_ex
add wave -noupdate -expand -group ISSUE -radix hexadecimal /top_tb/T1/funct_iss_ex
add wave -noupdate -expand -group ISSUE -radix hexadecimal /top_tb/T1/shamt_iss_ex
add wave -noupdate -expand -group ISSUE -radix hexadecimal /top_tb/T1/target_iss_ex
add wave -noupdate -expand -group ISSUE -radix hexadecimal /top_tb/T1/reg_src_iss_ex
add wave -noupdate -expand -group ISSUE -radix hexadecimal /top_tb/T1/reg_dst_iss_ex
add wave -noupdate -expand -group ISSUE -radix hexadecimal /top_tb/T1/jump_iss_ex
add wave -noupdate -expand -group ISSUE -radix hexadecimal /top_tb/T1/branch_iss_ex
add wave -noupdate -expand -group ISSUE -radix hexadecimal /top_tb/T1/mem_read_iss_ex
add wave -noupdate -expand -group ISSUE -radix hexadecimal /top_tb/T1/mem_to_reg_iss_ex
add wave -noupdate -expand -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]} {-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}} /top_tb/T1/alu_op_iss_ex
add wave -noupdate -expand -group ISSUE -radix hexadecimal /top_tb/T1/mem_wr_iss_ex
add wave -noupdate -expand -group ISSUE -radix hexadecimal -childformat {{{/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[1]} {-radix hexadecimal} {/top_tb/T1/alu_src_iss_ex[0]} {-radix hexadecimal}} /top_tb/T1/alu_src_iss_ex
add wave -noupdate -expand -group ISSUE -radix hexadecimal /top_tb/T1/reg_wr_iss_ex
add wave -noupdate -expand -group ISSUE -radix hexadecimal /top_tb/T1/sign_ext_iss_ex
add wave -noupdate -expand -group ISSUE -radix hexadecimal /top_tb/T1/sign_imm_iss_ex
add wave -noupdate -expand -group ISSUE -radix hexadecimal /top_tb/T1/sign_ext_iss
add wave -noupdate -expand -group ISSUE -radix hexadecimal /top_tb/T1/rd_iss_ex
add wave -noupdate -expand -group ISSUE -radix hexadecimal /top_tb/T1/rs_iss_ex
add wave -noupdate -expand -group ISSUE -radix hexadecimal /top_tb/T1/rt_iss_ex
add wave -noupdate -expand -group ISSUE -radix hexadecimal /top_tb/T1/r_data_p1_rf_iss_ex
add wave -noupdate -expand -group ISSUE -radix hexadecimal /top_tb/T1/r_data_p2_rf_iss_ex
add wave -noupdate -expand -group EXECUTE -radix hexadecimal /top_tb/T1/valid_ex_mem
add wave -noupdate -expand -group EXECUTE -radix hexadecimal /top_tb/T1/flush_ex
add wave -noupdate -expand -group EXECUTE -radix hexadecimal /top_tb/T1/alu_op_ex_mem
add wave -noupdate -expand -group EXECUTE -radix hexadecimal /top_tb/T1/alu_src_ex_mem
add wave -noupdate -expand -group EXECUTE -radix hexadecimal /top_tb/T1/reg_dst_ex_mem
add wave -noupdate -expand -group EXECUTE -radix hexadecimal /top_tb/T1/mem_to_reg_ex_mem
add wave -noupdate -expand -group EXECUTE -radix hexadecimal /top_tb/T1/mem_wr_ex_mem
add wave -noupdate -expand -group EXECUTE -radix hexadecimal /top_tb/T1/reg_wr_ex_mem
add wave -noupdate -expand -group EXECUTE -radix hexadecimal /top_tb/T1/sign_imm_ex_mem
add wave -noupdate -expand -group EXECUTE -radix hexadecimal /top_tb/T1/rd_ex_mem
add wave -noupdate -expand -group EXECUTE -radix hexadecimal /top_tb/T1/rs_ex_mem
add wave -noupdate -expand -group EXECUTE -radix hexadecimal /top_tb/T1/rt_ex_mem
add wave -noupdate -expand -group EXECUTE -radix hexadecimal /top_tb/T1/r_data_p1_alu_ex_mem
add wave -noupdate -expand -group EXECUTE -radix hexadecimal /top_tb/T1/r_data_p1_rf_ex_mem
add wave -noupdate -expand -group EXECUTE -radix hexadecimal /top_tb/T1/r_data_p2_alu_ex_mem
add wave -noupdate -expand -group EXECUTE -radix hexadecimal /top_tb/T1/r_data_p2_rf_ex_mem
add wave -noupdate -expand -group EXECUTE -radix hexadecimal /top_tb/T1/fwd_r_data_p1_alu_ex
add wave -noupdate -expand -group EXECUTE -radix hexadecimal /top_tb/T1/fwd_r_data_p2_alu_ex
add wave -noupdate -expand -group EXECUTE -radix hexadecimal /top_tb/T1/res_alu_ex_mem
add wave -noupdate -expand -group EXECUTE -radix hexadecimal /top_tb/T1/n_ex_mem
add wave -noupdate -expand -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
TreeUpdate [SetDefaultTree]
WaveRestoreCursors {{Cursor 1} {110 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 {0 ps} {202 ps}

error: pathspec 'mips/mips-pipeline/wave.do' did not match any file(s) known to git


Create bettertab.ado

Create bettertab.ado

*! V0.1 31012017, Apoorva Lal
// wrapper for tab / tab2 that adds value prefixes for factor variables
cap pr drop bettertab
pr def bettertab
	version 6
	syntax varlist [if] [in]
	marksample touse
	loc nvars : list sizeof varlist
	if `nvars' == 1 {
		loc tabcmd tab
	}
	else {
		loc tabcmd tab2
	}
	loc label_list ""
	foreach v in `varlist' {
		cap conf var `v'
		if !_rc {
			loc la_`v': value label `v'
			loc label_list `label_list' `la_`v''
		}
		else {
			noi di "`v' not found"
			error
		}
	}
	numlabel `label_list', add
	`tabcmd' `varlist'
	numlabel `label_list', remove
end

error: pathspec 'bettertab.ado' did not match any file(s) known to git


added clean

added clean

error: pathspec 'clean.do' did not match any file(s) known to git