Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[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   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: lowest value in a series of variables in wide data
Date   Tue, 28 May 2013 15:51:42 +0100

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
[email protected]


On 28 May 2013 15:44, Harrison Alter <[email protected]> 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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index