[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
"Nick Cox" <n.j.cox@durham.ac.uk> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
st: RE: egen index = group(X), label |

Date |
Thu, 26 Nov 2009 10:25:54 -0000 |

A gloss on David's trick is as follows. -egen, group()- always produces integers 1 up. Thus you need only find the highest such integer. You can also cut out the middle macro(s). egen index = group(X), label summ index, meanonly gr tw (scatter Y index, xlabel(1/`r(max)', val)) Nick n.j.cox@durham.ac.uk Airey, David C Suppose you have an index plot to make for Y against X, but X is not like: 1,2,3,4,5,6,7,8,9,10 (1) but like 1,8,9,13,18,120,140,141,142,300 (2) If you try -scatter Y X- the gaps in X make it unattractive for some purposes. But you can instead try: egen index = group(X), label summ index local xlo = r(min) local xhi = r(max) gr tw (scatter Y index, xlabel(`xlo'(1)`xhi', val)) Now the X axis will be as (1) but labeled as (2). A useful little note in egen rank() for group() in the PDF help suggested this trick. * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**References**:**st: egen index = group(X), label***From:*"Airey, David C" <david.airey@Vanderbilt.Edu>

- Prev by Date:
**st: AW: creating an ordered month variable over several years** - Next by Date:
**st: [POSSIBLE SPAM] xtgls** - Previous by thread:
**st: egen index = group(X), label** - Next by thread:
**st: [POSSIBLE SPAM] xtgls** - Index(es):

© Copyright 1996–2015 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |