Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: RE: generating new sorted ID variable


From   "Pagan, jose" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: generating new sorted ID variable
Date   Tue, 2 Dec 2003 14:36:31 -0500

Thanks Nick, your first suggestion works perfectly. This is exactly what
I needed! Regards, Jose.


Btw, my graph command is:
twoway rspike docin docun sortedid || bar uninsuredmw sortedid

The uninsuredmw mean comes out in ascending order, which is what I
wanted. 


-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Nick Cox
Sent: Tuesday, December 02, 2003 1:57 PM
To: [email protected]
Subject: st: RE: generating new sorted ID variable

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/

*
*   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/



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