Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: foreach question


From   Jeph Herrin <stata@spandrel.net>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: foreach question
Date   Mon, 13 Sep 2010 15:01:19 -0400


I think -rowsort- is your friend:

  ssc install rowsort
  rowsort Date1 Date2 Date3 Date4, gen(ndate1 ndate2 ndate3 ndate4)

hth,
Jeph



On 8/22/2010 3:54 PM, David Torres wrote:
Is there a way to sort or reorder dates using the foreach
command--perhaps using the egen function in the loop or something?

How do I get:

Date1 Date2 Date3 Date4

23July1997 01Jan1997 12Sept1997 03Feb1997

to be ordered thusly:

Date1 Date2 Date3 Date4
01Jan1997 03Feb1997 23July1997 12Sept1997

Thanks,

--
David Diego Torres

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