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: Need help sorting values


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Need help sorting values
Date   Sun, 17 Feb 2013 16:17:31 +0000

gen what = cond(report == "h&p", 0, cond(report == "end", 2, 1))

bysort patient (date what) :

If your variable -report- is numeric with value labels, there will be
a similar but not identical solution.

Nick

On Sun, Feb 17, 2013 at 3:32 PM, Michael Stewart
<michaelstewartresearch@gmail.com> wrote:

> I have data for different as follows
>
> pateint   date          report
> 111     2/15/2012       ed
> 111     2/15/2012       ed
> 111     2/15/2012       h&p
> 111     2/15/2012       d/c
> 111     2/15/2012       ed
> 111     2/15/2012       con
> 111     1/23/2012       con
> 111     1/23/2012       d/c
> 111     1/23/2012       ed
> 111     1/23/2012       con
> 111     1/23/2012       h&p
> 222   1/20/2012  ed
> 222    1/20/2012  h&p
> 222  1/20/2012   con
>
> My need is to sort the report variable for a particular date within a
> patient so that the h&p is the first value and ed is the last value
> i.e h&p is report[1] and ed is report[_N]
>
>
> something like bysort patient date: _ _ _ _ _
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index