Hello all:
I was trying to get median and IQR of multiple continuous variable by groups of a binary variable into a wrapper I want to create for calling in a putdocx statements. I saw Andrew Musau's post using frames earlier for collecting Chi-square results which seems neat but I could not quite configure it for my needs to call the values and levels as needed. So, I tried my version with local macros but I am not getting the loop right since the values are not showing up.
Have attached a sample with the auto dataset with mpg and length by foreign as the dichotomous variable.
I was trying to get median and IQR of multiple continuous variable by groups of a binary variable into a wrapper I want to create for calling in a putdocx statements. I saw Andrew Musau's post using frames earlier for collecting Chi-square results which seems neat but I could not quite configure it for my needs to call the values and levels as needed. So, I tried my version with local macros but I am not getting the loop right since the values are not showing up.
Have attached a sample with the auto dataset with mpg and length by foreign as the dichotomous variable.
Code:
sysuse auto, clear local v mpg length local f foreign levelsof `f', local(mylev) tabstat `v', by(`f') statistic(p25 p50 p75) save return list foreach v of local v{ forvalue j = 1/2 { mat list r(Stat`j') local `v'lqr`mylev' = r(Stat`j')[1,1] local `v'med`mylev' = r(Stat`j')[2,1] local `v'uqr`mylev' = r(Stat`j')[3,1] } } di "The median length in the domestic car group was `lengthmed0' (IQR: `lengthlqr0', `lengthuqr0')"
Comment