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]

st: bysort ptid providerid: how to perform computation at the patient-provider level


From   Dilip Pandey <[email protected]>
To   [email protected]
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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index