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


From   "Dr. Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: RE: bysort ptid providerid: how to perform computation at the patient-provider level
Date   Tue, 3 Aug 2010 18:48:45 +0200

<>

***********
clear*

inp byte(ptid providerid) str10(bill_from bill_thru)
1    1    20Sept2005      20Sept2005
1    1    21Sept2005      24Sept2005
1    2    25Sept2005      27Sept2005
1    3    28Sept2005      29Sept2005
1    3    30Sept2005      10Oct2005
end

compress
list, noobs  

gen from_dt=date(bill_from, "DMY")
gen thru_dt=date(bill_thru, "DMY")

form from_dt thru_dt %td

bys ptid providerid ( from_dt thru_dt): gen days = from_dt[_n+1] - thru_dt[_n]
l, noo sepby( ptid providerid)
***********


HTH
Martin

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Dilip Pandey
Sent: Dienstag, 3. August 2010 18:06
To: [email protected]
Subject: st: bysort ptid providerid: how to perform computation at the patient-provider level

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/


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