Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: RE: rearrange variables in a panel


From   "Alessandro Fiaschi" <alefiaschi@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: RE: rearrange variables in a panel
Date   Mon, 6 Nov 2006 11:03:39 +0100

Thank you very much.

All the best,

Alex

2006/11/6, Maarten Buis <M.Buis@fsw.vu.nl>:
---Alessandro Fiaschi wrote:
> Even if I add an "id (=1,2,3,...)" for each firm, "gsort id -time"
> makes only an order, but it doesn't rearrange data in the inverse
> order (from 2005 to 1993, in my case). Could you help me more? Thanks!

Alex:
I interpreted your question as: "I want to keep observations
belonging to the same firm together, but want to change the
sort order within each firm from most recent to least recent."
In that case you would type -gsort id -year-. I could have
also read your question as: "I want all the most recent
observation first and the least recent last." Then you would
type: --gsort -year id-. This is illustrated in the example
below.
HTH,
Maarten

*--------------begin example----------------
use http://www.stata-press.com/data/r9/pig, clear
list id week in 1/20, clean
gsort id -week
list id week in 1/20, clean
gsort -week id
list id week in 1/20, clean
*--------------end example------------------

-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting adress:
Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------



*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index