Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: RE: Reading multiple observations per line


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: RE: Reading multiple observations per line
Date   Fri, 30 Sep 2005 00:24:32 +0100

I too would be interested to see a more 
elegant solution. 

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

Raphael Fraser
 
> Thank you Nick!
> 
> I guess I should have stated I wanted a solution with Stata's
> dictionary. I did read your FAQ e-mail this morning. My memory is not
> that bad. This exercise is purely illustrative for a intro to stata
> class. Is there anyone with a more elegant solution.
> 
> On 9/29/05, Nick Cox <n.j.cox@durham.ac.uk> wrote:
> > Sure, if you prefer a more complicated
> > solution and more work.
> >
> > dictionary {
> >         str1 group1
> >         x1
> >         y1
> >         z1
> >         str1 group2
> >         x2
> >         y2
> >         z2
> > }
> >
> > infile ...
> >
> > gen id = _n
> > reshape long group x y z, i(id)
> > drop id
> >
> > There may be a simpler way with a dictionary,
> > but this should be (the sketch of) one solution.
> >
> > Nick
> > n.j.cox@durham.ac.uk
> >
> > Raphael Fraser
> >
> > > Can it be done using a dictionary?
> >
> > Nick Cox
> >
> > > > . infile str1 sex v1-v3 using fraser.dat
> > > >
> > > > This really is well covered by the online help.
> >
> > Raphael Fraser
> >
> > > > > I would like to read a series of variables; group, x, y,
> > > and z, where
> > > > > there are several sets of observations per line. Here are
> > > some sample
> > > > > lines of data.
> > > > >
> > > > > T 12 22 1478 F 18 20 1278 F 13 28 1077
> > > > > T 11 33 1789 T 17 29 1122 F 19 39 1557
> > > > >
> > > > > How can this be done? I tried using the dictionary but I
> > > don't know
> > > > > how to tell Stata that the second observation starts at
> > > column 14 and
> > > > > the third starts column 27.

*
*   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