Bookmark and Share

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

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

st: Query regarding changing dates and events

From   Ricardo Castro <>
Subject   st: Query regarding changing dates and events
Date   Wed, 7 Apr 2010 09:40:31 -0400

Hi to all:

I need assistance with the following query regarding dates:

I have a hospital dataset with 3 columns: patient id (patid),
admission date (admit) and discharge date (disch). In another dataset
I have a variable varr with a numerical value (like a dose of a drug)
that is recorded for every day (of course its value is different for
every day).

What I need is to assign for every patient the total amount of varr
according to the specific days he/she was hospitalized, to finally sum
them up and obtain a total dose of varr for every patient during
his/her hospitalization.

Before doing that, I think I need to have one row for every day of
hospitalization, to combine with the varr database. I have tried with
the expand command but it clones the dates and does not generate
sequentially a number of rows according to the number of
hospitalization days (keeping the same patid).


Patid    admit     disch

1001     05jan2010 10jan2010

I need…

Patid    admit     disch       day

1001     05jan2010 10jan2010   05jan2010

1001     05jan2010 10jan2010   06jan2010

1001     05jan2010 10jan2010   07jan2010

1001     05jan2010 10jan2010   08jan2010

1001     05jan2010 10jan2010   09jan2010

1001     05jan2010 10jan2010   10jan2010

After that I need to attribute the varr value to every date day for
every patient.

Can you help me with this? or if is there a more elegant way of doing
what I need, I will greatly appreciate that information.

Many thanks


*   For searches and help try:

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