Gawrich Stefan wrote:
> I want to obtain aggregate values (e.g. median age by sex) from an
> individual data set and generate locals out of them (to show the values in
> a textbox in a graph).
Others have proposed different solutions. Here is one that tries to be fast:
. _pctile age if sex==1
. local female_medage = r(r1)
. _pctile age if sex==2
. local female_medage = r(r1)
or, slighly more general:
. levelsof sex, local(K)
. foreach k of local K {
. _pctile age if sex == `k'
. local medage`k' = `r1'
. }
(This produces local macros medage1 and medage2)
The major lesson to be learned from this and the other solutions is to work
with "saved results" (See -help return-, or chapter 4 in Kohler/Kreuter "Data
Analysis Using Stata")
hope this helps
Uli
--
[email protected]
+49 (030) 25491-361
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/