Skip to content

Commit

Permalink
Update csdid2_plot.ado
Browse files Browse the repository at this point in the history
  • Loading branch information
friosavila committed Mar 15, 2024
1 parent fc259d7 commit bdd9f21
Showing 1 changed file with 41 additions and 10 deletions.
51 changes: 41 additions & 10 deletions csdid2/csdid2_plot.ado
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ program csdid2_plot_wh
// Group Calendar
tempvar t b ll uu se all auu
mata:other_p2("`t' `b' `ll' `uu' `se' `all' `auu'","`tbl'", `=`level'/100')
`t' `b' `ll' `uu' `se' `all' `auu'
csdid_plot_other `t' `b' `ll' `uu' `all' `auu', `options' ktype(`ktype') asy
}
else {
Expand Down Expand Up @@ -115,9 +114,10 @@ mata:
tnv = tokens(newvars)
real matrix ss
ss= _st_addvar(sprintf("str%f",max(strlen(ntbl))),tnv[1])
ss= _st_addvar("double",tnv[2..4])
ss= _st_addvar("double",tnv[2..7])
st_sstore((1::rows(tbl)) ,tnv[1],ntbl)
st_store((1::rows(tbl)) ,tnv[2..4],tbl)
st_store((1::rows(tbl)) ,tnv[2..7],tbl)
}
end

Expand Down Expand Up @@ -243,8 +243,8 @@ end
program csdid_plot_other
syntax varlist, [ktype(int 3) * ///
xtitle(passthru) ytitle(passthru) ///
legend(passthru)]
gettoken t rest:varlist
asy legend(passthru) format(passthru)]
gettoken t rest:varlist
gettoken b rest:rest
gettoken ll rest:rest
gettoken uu rest:rest
Expand All @@ -264,9 +264,8 @@ program csdid_plot_other

mata:st_local("adj",strofreal(csdid.antici))

tempvar t2

qui:encode `t', gen(`t2')
tempvar t2
qui:myencode `t', gen(`t2') `format'
if "`asy'"=="" {
two (`style' `ll' `uu' `t2' , `gf11' ) ///
(scatter `b' `t2' , `gf12' ) , ///
Expand All @@ -278,8 +277,9 @@ program csdid_plot_other
//gettoken se rest:rest
gettoken all rest:rest
gettoken auu rest:rest
two (`style' `ll' `uu' `t2' , `gf11' ) ///
(`style' `all' `auu' `t2' , lwidth(3) `gf11' ) ///

two (`style' `ll' `uu' `t2' , `gf11' lwidth(1)) ///
(`style' `all' `auu' `t2' , `gf11' ) ///
(scatter `b' `t2' , `gf12' ) , ///
legend(off) `xtitle' `ytitle' ///
yline(0 , lp(dash) lcolor(black)) `title' ///
Expand All @@ -289,3 +289,34 @@ program csdid_plot_other

end

program drop myencode
program myencode
syntax varname, gen(name) [format(string asis)]
if "`=`varlist''"=="GAverage" {
local torep "GAverage"
*replace `varlist' = `varlist'[2]-(`varlist'[3]-`varlist'[2])
}
if "`=`varlist''"=="TAverage" {
local torep "TAverage"
*replace `varlist' = `varlist'[2]-(`varlist'[3]-`varlist'[2])
}

if "`torep'"!="" {
replace `varlist'=subinstr(`varlist',"g","",1) if _n>1
replace `varlist'=subinstr(`varlist',"t","",1) if _n>1
}
else {
replace `varlist'=subinstr(`varlist',"g","",1)
replace `varlist'=subinstr(`varlist',"t","",1)
}
qui:destring `varlist', force gen(`gen')
if "`torep'"!="" {
replace `gen' = `gen'[2]-(`gen'[3]-`gen'[2]) in 1
tempname aux
label define _aux_ `=`gen'[1]' "`torep'", modify
label values `gen' _aux_
}
qui format `format' `gen'
end


0 comments on commit bdd9f21

Please sign in to comment.