I'm writing an SCM command, and I like to inform users of when the intervention was measured between, partly so it's clear and also so if they can see if they did something wrong (wouldn't wanna say COVID-19 happened in 1920, after all).
Let's use an example!
The message I display at the end is what my program spits out when describing the dates of the intervention units. However, it says "Treatment is measured from 209 to 230".
Strictly speaking, I don't and likely shouldn't care about this; I know what it means, Stata knows what I/the users mean, and everything else proceeds accordingly. But, I don't like displaying the dates in the numerical format unless of course it's the year.
How might I display the time variables, any time variables, in the manner the user's formatted them in? I know when you use xtset, you get the r(tsfmt) macro, so I suspect this is part of the fix, by how would I use this or another technique to get Stata to display
"disp "Treatment is measured from 2012q2 to 2017q3"
Let's use an example!
Code:
*Boring Data Management Stuff qui { u "https://github.com/ebenmichael/augsynth/raw/master/data-raw/kansas_longer2.dta", clear keep if year > = 1990 g time = yq(year, qtr) format %tq time loc int_time: disp tq(2012q1) g treated = 1 if time > `int_time' & Fi == 20 replace treated = 0 if mi(treated) keep Fi treated time gdp levelsof Fi if treated == 1, l(mun) qui g relative = . cls foreach units of loc mun { qui su time if treated ==1 & Fi ==`units', mean qui replace relative = time - `r(min)' if Fi ==`units' } cls tempvar obs_count qbys Fi (time): g `obs_count' = _N qui su `obs_count' qui drop if `obs_count' < `r(max)' } xtset Fi time, q su time if treated disp "Treatment is measured from `r(min)' to `r(max)'"
Strictly speaking, I don't and likely shouldn't care about this; I know what it means, Stata knows what I/the users mean, and everything else proceeds accordingly. But, I don't like displaying the dates in the numerical format unless of course it's the year.
How might I display the time variables, any time variables, in the manner the user's formatted them in? I know when you use xtset, you get the r(tsfmt) macro, so I suspect this is part of the fix, by how would I use this or another technique to get Stata to display
"disp "Treatment is measured from 2012q2 to 2017q3"
Comment