The sorted ids can be got with
egen SortedID = group(X ID)
although it's possible that the variant
-egroup()- in -egenmore- on SSC may be
closer to what you want.
How does the graph you want with -twoway bar-
differ from what you can get with
graph bar response, over(id, sort(1))
Nick
[email protected]
Pagan, jose
> I have a variable called ID that goes from 1 through 60, and an X
> variable that takes the same value within each ID value (I have an
> unbalanced panel of about 50,000 obs). I want to create a new ID
> variable that is sorted in ascending or descending order by
> X so that I
> can do a sorted twoway bar graph. Or, better byyet, is there
> a way to sort
> twoway bar or rspike graphs? Sorted graphs seem to be an option for
> 'graph bar' but not for 'twoway bar'. Thanks for your help, Jose.
>
> For example:
>
> ID X SortedID or SortedID
> 1 4 2 2
> 1 4 2 2
> 1 4 2 2
> 2 7 1 3
> 3 2 3 1
> 3 2 3 1
*
* 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/