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


From   "Dr. Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
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: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Dilip Pandey
Sent: Dienstag, 3. August 2010 18:06
To: statalist@hsphsun2.harvard.edu
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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index