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]

st: difference between rows


From   "Dougie Elder" <d.elder@dundee.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
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


Dougie





*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


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