Hello
I am struggling to store the results of ttest in matrix using loops. I have stname (string variable ) representing state and also state (numeric). I tried using both strings and numerics but not successful. i would like to have to state name also in the output matrix. Kindly help
Below is the code:
------------------------------------------------------------------------------------------------------------------------------------------------------------------
foreach s in "Andhra Pradesh" "Karnataka" "Rajasthan" {
foreach v of varlist $metric_imp {
ds `v'
ds `s'
di `"`: var label `v''"'
capture noisily ttest `v' if stname==`s', by (sample)
*gen stname="Andhra Pradesh"
matrix ap_metric_t= (`s' r(N_1), r(N_2), r(p), r(p_l), r(p_u), r(t))
matrix rownames ap_metric_t= `v'
*matrix colnames AP_int4 = N1 N2 pscore pscorel pscoreu t
mat2txt, matrix(ap_metric_t) sav("census_metric_t.xlx") append
}
}
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
Related Posts with t test output in matrix using loops
Issues with running stata code for cnormI have issues running the stata code for cnorm as shown below, is there any way to resolve this issu…
Stata 17 Speed vs Stata 16.1 SpeedFirst of all, congratulations to all for getting the New update. It is great to see STATA putting ef…
DEA with loopSuppose I have a set of 100 hospitals and each hospital has an observation for four years. I want to…
Outcomes for fixed effectsDear all, I will please like to know if i can use two different outcomes for a fixed effects. I am …
Generating new variable in a panel dataset with values of first time periodHi everyone! Apologies for the vague title. I have a variable (URBAN) that defines each village (IDP…
Subscribe to:
Post Comments (Atom)
0 Response to t test output in matrix using loops
Post a Comment