Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st:How to input a portion of a file


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st:How to input a portion of a file
Date   Wed, 20 Feb 2008 11:35:02 -0000

I am not clear how that this will help, as the header text and the
remainder of the file will give -insheet- quite different ideas about
what variables there are. 

Nick 
n.j.cox@durham.ac.uk 

Friedrich Huebler

You wrote that -insheet- with subsequent deletion of unwanted data is
"sloppy". That approach might still be the easiest if all files have
the same structure and your data always appear in the same columns.

. insheet using filename, nonames
. drop if _n < 30 | _n > 129
. drop v1 - v20 v25 - v30

On Feb 18, 2008 9:26 AM, Joseph Wagner <joseph.wagner@wright.edu> wrote:
> I have data I wish to input a portion of into STATA.  Data is
collected
> on patients by a machine that measures their gait as they walk.  A
text
> file is output for each patient with columns representing variables
> (each about 130 lines long) but the multiple observation data doesn't
> start until line 29.  The first 28 lines are taken up with short lines
> of data describing the patient.  Unfortunately, I also need a couple
of
> those lines in 'header' area.  The 29th line has the variables names
but
> they do not line up directly with the columns of data so I figured I
> could just label the data later.  The data I need starts 30 lines down
> at column 115 and includes the next 4 columns and goes down 100 lines.
>
> I realize there are easier ways to do this but I have data on about
300
> patients (and so one file for each person) and wanted to automate this
> input (followed by successive merging of files to get my final
dataset).
>
> I wanted to use the -infix- command but have never used this command
> before and my attempts so far have failed.  I also tried using
-infile-
> with the _first(30) option and the _line(30) option but those didn't
> seem to work either.
>
> Here is a dictionary I attempted with just one of the variables:
>
> dictionary using "c:\data\gait\SBS00001_20050607_1.nrm" {
>        _line(30)
>        _column(115) r_grf_vrt_frc %5f
> }
>
> infile using SBS00001_20050607_1.dct
>
> unexpected end of file
> (5 observations read)
>
> The other problem is that it didn't seem to pull the data
corresponding
> to that column.  I thought perhaps there was a problem with the data
not
> being in a fixed format but if I try -insheet- all the data imports
and
> the correct data lines up in the individual columns.  Of course I
could
> write some programming whereby I delete the unneeded variables and
line
> but that's kind of sloppy.
>
>
>
> I am using STATA ver. 8.2

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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   |   What's new   |   Site index