I am trying to use the community-contributed command frmttable
in Stata to generate a table summary statistics of date variables.
However, when I execute the command, the summary statistics are not in the date format, but rather are integers. I would like them to be displayed in a MDY
format: %dtNN/DD/CCYY
The problem is shown below:
Step Dates
-------------------
Step Date
-------------------
Step 1 17,206
Step 2 17,241
Step 3 17,258
Step 4 17,619
Step 5 17,958
Step 6 18,401
Step 7 18,464
Step 8 18,976
Step 9 18,965
Step 10 19,243
Step 11 19,064
-------------------
I am not considering other table exporting commands since frmttable
gives me the most flexibility. I am also trying to export the table into LaTeX
.
Example data can be found below:
* Example generated by -dataex-. To install: ssc install dataex
clear
input double Step_n float Date
2 17206
2 17234
3 17241
3 17339
4 17258
4 17626
5 17619
5 17619
5 18155
6 17958
6 19339
7 18401
7 18662
8 18464
8 19001
8.5 18976
8.5 19267
9 18965
9.5 19243
10 19064
10 20227
end
format %tdNN/DD/CCYY Date
The code I used is the following:
matrix m1 = J(11,1,.)
local i = 1
foreach s of numlist 2/8 8.5 9 9.5 10 {
quietly summarize Date if Step_n==`s'
matrix m1[`i',1]=r(min)
local i = `i' + 1
}
matrix rownames m1 = "Step 1" "Step 2" "Step 3" "Step 4" ///
"Step 5" "Step 6" "Step 7" "Step 8" "Step 9" "Step 10" "Step 11"
matrix list m1, format(%tdNN/DD/CCYY)
frmttable using m1.tex, statmat(m1) title("Step Dates") ///
sdec(0) ctitle("Step","Date") replace tex