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: bysort ptid providerid: how to perform computation at the patient-provider level


From   Dilip Pandey <dpandey1@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: bysort ptid providerid: how to perform computation at the patient-provider level
Date   Tue, 3 Aug 2010 11:05:33 -0500

Dear Statalist;
I am STATA 11 user.
I am analyzing large panel data

I want to generate lapsed days between two bills submitted by a
patient's provider.

Example of dataset:
ptid      providerid       bill_from           bill_thru             days
1            1                20Sept2005      20Sept2005
1            1                21Sept2005      24Sept2005
1            2                25Sept2005      27Sept2005
1            3                28Sept2005      29Sept2005
1            3                30Sept2005      10Oct2005
2
2
2
3
3
3
so on

I use following STATA cmd:

. sort ptid (providerid) (bill_from) (bill_thru)
. by ptid (providerid): gen days = from_dt[_n+1) - thru_dt[_n]

STATA computes days at ptid level not at the pt-provider level:

ptid      providerid       bill_from           bill_thru             days
1            1                20Sept2005      20Sept2005        .
1            1                21Sept2005      24Sept2005        1
1            2                25Sept2005      27Sept2005        1
1            3                28Sept2005      29Sept2005        1
1            3                30Sept2005      10Oct2005          1
2
2

The "by"  performs command at the ptid level (only verifies that data
are sorted by ptid and providerid)
I want to compute days lapsed between bills of a provider, not between
two providers.  (days for provider should be (.))


I will highly appreciate suggestion on Stata code to compute at the
pt-provider specific level.

Thanks.
Dilip

*
*   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