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 on April 23, and its replacement, is already up and running.

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

st: difference between rows

From   "Dougie Elder" <>
To   <>
Subject   st: difference between rows
Date   Fri, 20 May 2011 23:10:54 +0100

Apologies if this is quite basic, but I've searched everywhere and I cant
find the answer !

I have a pile of drug prescription data.

Each patient has several rows of prescriptions e.g.

Id       start_date    days  missed days
Pt1   10/12/08          21
Pt1  10/01/09          38
Pt1  14/03/09          36
Pt1  15/04/10          36
Pt2  02/05/09          90
Pt2  03/06/10          32

I need to calculate the no of days where no drug was available in each row
of data i.e calculate the difference between 10/12/08 and 10/01/09 and place
the result of ((10/01/09 - 10/12/08)-21 ) at the end of row 1

Obviously only for each pt


*   For searches and help try:

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