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: Tips for writing code to consolidate observations?
From
"David Radwin" <[email protected]>
To
<[email protected]>
Subject
st: RE: Tips for writing code to consolidate observations?
Date
Tue, 13 Nov 2012 13:28:04 -0800 (PST)
Like this?
bysort ID (GCS): keep if _n==1
David
--
David Radwin
Senior Research Associate
MPR Associates, Inc.
2150 Shattuck Ave., Suite 800
Berkeley, CA 94704
Phone: 510-849-4942
Fax: 510-849-0794
www.mprinc.com
> -----Original Message-----
> From: [email protected] [mailto:owner-
> [email protected]] On Behalf Of David
> Sent: Tuesday, November 13, 2012 1:00 PM
> To: [email protected]
> Subject: st: Tips for writing code to consolidate observations?
>
> I have a large dataset that has multiple observations per individual
> and need to convert to single line observations (9,000 lines rows but
> really only a few hundred subjects). The data columns that account
> for the multiple observations are unnecessary (see below, e.g.,
> ICD-9). The first occurrence of the data that I need to capture is
> the first time the observation occurs. As there are about 500
> subjects, I was hoping there is some code to convert to single
> observations/line. See the example below of what I have and what I
> would like it to look like.
>
>
> (RAW DATA)
>
> ID ICD-9 GCS AIS1 AIS2 AIS3 AIS4 AIS5 AIS6
>
> 1 823.2 15 0 1 1 1 0 0
> 1 849.5
> 1 823.5
> 2 849.1 12 0 1 3 3 2 1
> 3 813.4 11 0 0 3 3 7 7
> 3 775.1
>
>
> (IDEAL Final Product)
>
> ID GCS AIS1 AIS2 AIS3 AIS4 AIS5 AIS6
>
> 1 15 0 1 1 1 0 0
> 2 12 0 1 3 3 2 1
> 3 11 0 0 3 3 7 7
>
>
> Much appreciated,
>
> David Zonies, MD MPH
> Landstuhl Regional Medical Center
> Landstuhl, Germany
*
* 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/