Statalist


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

st: egen index = group(X), label


From   "Airey, David C" <[email protected]>
To   Statalist <[email protected]>
Subject   st: egen index = group(X), label
Date   Thu, 26 Nov 2009 01:44:15 -0600

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/



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