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]

Re: st: Linking a patient file with an event file


From   Health Services PhD <[email protected]>
To   [email protected]
Subject   Re: st: Linking a patient file with an event file
Date   Thu, 28 Feb 2013 13:13:15 -0500

Hi Carl and others,

Thanks for the quick reply. I appreciate your time.

It sounds like you're suggesting that I'll end up with one observation
per person plus a count variable, is that correct? Unfortunately, each
visit could have different diagnosis codes and other visit-associated
information (dates, providers) that I need to retain. Are there other
approaches to doing so?

Lisa


On Thu, Feb 28, 2013 at 12:51 PM, Carl Severson <[email protected]> wrote:
> Hi Lisa,
>
> You are on the right track. Try this:
>
>      by id2013: gen edcount = _n
>      by id2013: gen temp = _N
>      keep if edcount == temp
>      drop temp
>
> Now you have one observation per person (making it easy to merge the
> visit data to your sociodemographic data) and the variable edcount
> will contain a value corresponding to the number of visits each person
> had, which I think is what you said you needed.
>
> Good luck.
> Carl
>
> p.s. I work with the same kind of data all the time so if you have
> more questions, feel free to ask.
>
> On Thu, Feb 28, 2013 at 10:15 AM, Health Services PhD
> <[email protected]> wrote:
>> I want to link/merge several files, but my data are complicated and
>> I’m unsure how to proceed. I'm using Stata 11.2 for Windows.
>>
>> My patient file contains sociodemographic information for ~60,000
>> patients. My event file contains information about ~20,000 visits to
>> emergency rooms. There is a patient ID variable in each file. Many
>> patients in my patient file will not be in my event file (because they
>> didn't visit the emergency room). My event file has a patient ID,
>> service date, and various other variables related to the visit.
>>
>> I need to merge the files so I can analyze incidence and run
>> regression models. I've read lots about merging files, but haven't
>> seen anything that addresses my issue yet.
>>
>> I assume I will need to reshape my event file from long to wide so
>> that there is one row per patient, but everything I read about
>> reshaping assumes that the multiple observations per patient are
>> identified somehow. So one thing I *think* I need to do is generate a
>> new variable that counts ED visits for each patient. I thought I might
>> be able to do something like this: (from
>> http://www.stata.com/support/faqs/data-management/creating-group-identifiers/)
>>
>> by id2013: gen edcount = 1 if _n==1
>> replace edcount = sum(edcount)
>>
>> But that gives me a sequential number that doesn't restart at 1 for
>> each new patient ID.
>>
>> Is reshaping the right approach, and if so, how do I best create the
>> variable I need?
>>
>> Thanks in advance for your time,
>> Lisa
>>
>> *
>> *   For searches and help try:
>> *   http://www.stata.com/help.cgi?search
>> *   http://www.stata.com/support/faqs/resources/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/faqs/resources/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/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index