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: lowest value in a series of variables in wide data


From   Harrison Alter <doctordad@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: lowest value in a series of variables in wide data
Date   Tue, 28 May 2013 17:06:58 -0700

Magic!

Thanks so much.

Harrison

On Tue, May 28, 2013 at 7:51 AM, Nick Cox <njcoxstata@gmail.com> wrote:
> The -egen- function -min()- takes an expression, but a varlist is not
> an expression. (Loosely, an expression can be evaluated as a single
> value.)
>
> It sounds as if you want first -rowmin()- not -min()-.  Important to
> spell out a -double- type for the result.
>
> egen double timein = rowmin(los*)
>
> It may be that you then want to apply
>
> ... min(), by(patientid)
>
>
> Nick
> njcoxstata@gmail.com
>
>
> On 28 May 2013 15:44, Harrison Alter <doctordad@gmail.com> wrote:
>> I have a dataset of hospital stay records in which each row is a
>> subject, and many of the columns are time stamps, each varname
>> beginning with "los_", e.g. "los_admfloor" or "los_dcsdu". These are
>> doubles using -clock-.
>>
>> To calculate the absolute length of stay, I want to generate a
>> variable, say, "timein" with the earliest time stamp, and one
>> "timeout" with the last, then subtract "timein" from "timeout".
>>
>> To generate these variables in Stata 11.2 on a Mac, I tried:
>>
>>  egen timein = min(los*), by ( patientid)
>>
>> which returns
>>
>> los* invalid name
>>
>> What's the best way to identify the minimum value among the variables
>> beginning with "los"?
>>
>> Thanks fo any advice you can provide.
>>
>> Harrison Alter
>> *
>> *   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/
> *
> *   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/



-- 
Harrison Alter, MD, MS, FACEP
Research Director
Department of Emergency Medicine
Alameda Health System - Highland Hospital
1411 East 31st Street
Oakland, California 94602

Executive Director
Andrew Levitt Center for Social Emergency Medicine
levittcenter.org
*
*   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