Hi,
In my data set, I have a control and treatment group. I am trying to take the mean, standard error, and p-value for them into an excel sheet. I used a loop for this:
The loop gave me the following new variables that I am posting using dataex. I tried to convert the different variables and their single value to a matrix using mkmat. However, it is not working. Any help would be highly appreciated.
In my data set, I have a control and treatment group. I am trying to take the mean, standard error, and p-value for them into an excel sheet. I used a loop for this:
Code:
foreach x in N_baseline {
qui gen `x'_T1=`x' if vote==1
qui gen `x'_T2=`x' if vote==0
foreach k in T1 T2 {
egen m_`k'=mean(`x'_`k')
local m_`k' = m_`k'
egen sd_`k'=sd(`x'_`k')
local sd_`k'= sd_`k'
}
quietly reg `x' vote, r
quietly test vote = 0
gen p_1= r(p)
local p_1 = p_1
qui g nb_T1=1 if `x'!=.&vote==1
qui egen N_T1=total(nb_T1)
local N_T1 N_T1
qui g nb_T2=1 if `x'!=.&vote==0
qui egen N_T2=total(nb_T2)
local N_T2 N_T2
display "`x'" "," `N_T1' "," `m_T1' "," `sd_T1' "," `N_T2' "," `m_T2' "," `sd_T2' "," "," `p_1'
return list
}
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float(m_T1 sd_T1 m_T2 sd_T2 p_1 N_T1 N_T2) 16.26087 5.543504 16.065218 5.174305 .86148 46 46 16.26087 5.543504 16.065218 5.174305 .86148 46 46 16.26087 5.543504 16.065218 5.174305 .86148 46 46 16.26087 5.543504 16.065218 5.174305 .86148 46 46

Comment