How can we modify this code to generate t-stat of the means instead of standard deviation (sd), and also for 4*4 sorts.

Code:
frame create means_and_sds int (idiovol_group mcap_group) ///
    float(mean_vw sd_vw mean_ew sd_ew)
forvalues iv = 1/5 {
    forvalues mc = 1/5 {
        summ vw_mean_q`mc'_idiovol_q`iv'_rt
        local mean_vw = r(mean)
        local sd_vw = r(sd)
        summ ew_mean_q`mc'_idiovol_q`iv'_rt
        local mean_ew = r(mean)
        local sd_ew = r(sd)
        frame post means_and_sds (`iv') (`mc') (`mean_vw') (`sd_vw') ///
            (`mean_ew') (`sd_ew')
    }
}
frame change means_and_sds
rename (mean* sd*) =_idiovol_
reshape wide *_idiovol_, i(mcap_group) j(idiovol_group)