Hi All,
I am trying to list results from a sumarise command under loop. The below code works fine and display the results stored in global macro. However, I would like to have them listed as one table (like a matrix for, example, instead of displaying them one by one. How can I do this? I like my final table/matrix to be with columns for the local macros 'hr' and 'hrpop' and rows for var1, var2 and var3. How can I incorporate it in the code below? Thanks.
I am trying to list results from a sumarise command under loop. The below code works fine and display the results stored in global macro. However, I would like to have them listed as one table (like a matrix for, example, instead of displaying them one by one. How can I do this? I like my final table/matrix to be with columns for the local macros 'hr' and 'hrpop' and rows for var1, var2 and var3. How can I incorporate it in the code below? Thanks.
Code:
local wt "mult" local z "PL" tempvar ind local i=0 local subtr "var1 var2 var3" foreach X of local subtr{ qui gen dum`i' = 0 qui replace dum`i' = 1 if `X'<=`z' qui sum dum`i' [fw=`wt'] local hr = r(mean) local pop= r(N) local hrpop=`hr'*`pop' global C`i' = `hr' global C`i'_n=`hrpop' drop dum`i' local ++i } display "C0 = " %9.4f $C0 display "Number = " %9.0f $C0_n display "C1 = " %9.4f $C1 display "Number = " %9.0f $C1_n display "C2 = " %9.4f $C2 display "Number = " %9.0f $C2_n
Comment