I am using data from the IPUMS-CPS ASEC series. I am looking to calculate the median income for each age and for each education category. A sample of the data for only 16 year olds is as follows:
Code:
year    age   educ    inc    weight
1992    16    "HS"    1000    20
1992    16    "CG"    1200    23
1993    16    "CG"    1400    24
1994    16    "HS"    1500    19
In short, there is data from multiple years with different educational categories. What I want to do is to calculate median income for 16 year olds (and subsequently for all of the ages from 16-65) by age and education.

I have tried the following:
Code:
bysort age educ: egen inc_median_age_educ = median(inc)
I think this works well, but there are two issues:

1. I cannot include the weights variable in this generation, which makes this wrong. In this FAQ, I am not sure I can include two level variables: https://www.stata.com/support/faqs/d...ry-statistics/. Kindly correct me if I'm wrong.

2. Would there be a way to export this to an external txt/xls file rather than adding an additional column? For now I am using the following:

Code:
#delimit ;
tabulate age [aw = weight], summ(inc_median_age_educ) means;
/*or*/

/*doesn't work, creates N and mean for age and education separately*/
tabout age educ [aw = weight] using try.xls, replace format(8) ptotal(none) lines (none)
sum cells(N wage_median_age_educ mean wage_median_age_educ);
Would there be a way to find this mean/median using tabout since it allows to export without creation of additional columns?

I am using Stata/SE 16.1 on Windows 10.