Statalist


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

st: RE: Is there a command similar to "bys" if I want to gsort the variables?


From   "Kieran McCaul" <[email protected]>
To   <[email protected]>
Subject   st: RE: Is there a command similar to "bys" if I want to gsort the variables?
Date   Fri, 4 Dec 2009 05:05:13 +0800

...

Is this what you want?


input year area
2000 1
2000 1
2000 2
2000 2
2001 1
2001 2
2001 3
2001 3
2001 3
2001 4
2002 2
2002 2
2002 4
2003 3
2003 3
2003 6
2003 6
end


gsort year -area, gen(order)
list
d, short

by order:gen num=_n
list

______________________________________________
Kieran McCaul MPH PhD
WA Centre for Health & Ageing (M573)
University of Western Australia
Level 6, Ainslie House
48 Murray St
Perth 6000
Phone: (08) 9224-2701
Fax: (08) 9224 8009
email: [email protected]

http://myprofile.cos.com/mccaul
http://www.researcherid.com/rid/B-8751-2008
______________________________________________
If you live to be one hundred, you've got it made.
Very few people die past that age - George Burns

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of
[email protected]
Sent: Thursday, 3 December 2009 11:55 PM
To: statalist
Subject: st: Is there a command similar to "bys" if I want to gsort the
variables?

Dear statalists,

Is there a command similar to "bys" if I want to gsort the variables?

For example,

bys year (area): g num=_n


However, I want to gsort the variable of area.


I have tried as followings,

gsort year -area

by year: g num=_n


Is there an easier way to do it just like -bys-?


By the way, when I typed "d,short" after I typed "gsort year -area", the
result was as followings,

Contains data from study.dta
  obs:           155                          
 vars:             6                          5 Jun 2009 01:45
 size:         3,875 (99.9% of memory free)
Sorted by:  year

Why the sorted variable did not contain area?

Thank you for any help!

Best regards,

Rose
 

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


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