Simplify to
infile str80 (v1-v7) using <whateverfile>, byvariable(5)
foreach v of var * {
capture rename `v' `=`v'[1]'
}
drop in 1
compress
Nick
[email protected]
Nick Cox
> In this case, I would go back a step and read in the data using
> -infile, byvariable()-.
>
> For your example set, you need 7 string variables,
> and 5 observations,
> and there are no blanks within strings, so try
>
> forval i = 1/7 {
> local args "`args' str80 v`i'"
> }
>
> infile `args' using <whateverfile>, byvariable(5)
>
> foreach v of var * {
> capture rename `v' `=`v'[1]'
> }
>
> drop in 1
>
> compress
>
>
> > 1 foo1.chp foo2.chp foo3.chp foo4.chp
> > 2 Date 10/11/04 10/11/04 10/11/04 10/11/04
> > 3 type U133A_2 U133A_2 U133A_2 U133A_2
> > 4 group lymph lymph lymph heart
> > 5 noise 1.4 1.24 1.5 1.25
> > 6 bkd 46.7 50.4 32.4 18.6
> > 7 bkdsd .28 .28 .26 .09
>
> Nick
> [email protected]
>
> Wallace, John
>
> > I've come across what appears to be a simple transposition
> > problem, but I'm unable to solve it. I have a tab-delimited
> > text-file data source where the records are columns and the
> > variables are rows. The variable labels are effectively the
> > first column, and the record labels are the first row, thus:
> >
> > v1 v2 v3 v4 v5
> > 1 foo1.chp foo2.chp foo3.chp foo4.chp
> > 2 Date 10/11/04 10/11/04 10/11/04 10/11/04
> > 3 type U133A_2 U133A_2 U133A_2 U133A_2
> > 4 group lymph lymph lymph heart
> > 5 noise 1.4 1.24 1.5 1.25
> > 6 bkd 46.7 50.4 32.4 18.6
> > 7 bkdsd .28 .28 .26 .09
> >
*
* 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/