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 on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Import data with complex structure


From   Pietro Manuel Ferraro <manuel.ferraro@hotmail.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: Import data with complex structure
Date   Wed, 13 Mar 2013 12:19:55 +0100

Dear Statalist,

I have a .txt file I would need to input in Stata and I can't figure out how
to do it. Basically, the file has data from about 1500 patients who
undergone ambulatory blood pressure monitoring (ABPM). Some of these
patients have more than one ABPM exam.

The file is structured so that:
- the first line has headers for the second line (name, surname, date of
birth, sex, etc.)
- the second line has patient-level data (see above)
- the third line is empty
- the fourth line has headers for the fifth line (date of measurement,
instrument type, etc.)
- the fifth line has ABPM-level data (see above)
- the sixth line is empty
- the seventh line has headers for the following lines (hour, systolic blood
pressure, diastolic blood pressure, heart rate etc.)

Then a variable number of lines follow, depending on the number of
measurements for that particular ABPM exam.

After the lines with measurement-level data, the file starts again with
headers for the next patient. I found here on the list a similar topic in
which someone suggested to treat each level separately and then merge the
files together, but I'm unable to implement such strategy since: 1) the
lower-level data (e.g., ABPM exams for each patient and measurements for
each ABPM) don't have any identifier for the higher levels 2) the headers
are repeated along the file 3) each patient may have a variable number of
ABPM exams and each ABPM exam may have a variable number of measurements, so
I can't instruct Stata to jump to pre-specified lines.

The file appears to be like this (with fictitious data):

=====start file=====
Surname          Name  Address           Phone              Dob     Sex
Weight             Height
DOE   JOHN                         01/12/1925    M         67        170

ABPM Date    Wake up(hr)    Rest(hr)           Therapy(hr)     Type
Instrument
19/02/2003    7          23                    24        TM2430

Date    Hour    Sys       Dia      HR
19/02/2003    09:22   120      80        60                    
19/02/2003    09:31   130      80        58                    
19/02/2003    09:45   120      80        60
.

Surname          Name  Address           Phone              Dob     Sex
Weight             Height
WRIGHT        JACK                          01/10/1974    M         88
180
.
=====end file=====

Any idea how to proceed?

Thanks,
Manuel

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index