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

st: Re: xpose command


From   "Scott Merryman" <[email protected]>
To   <[email protected]>
Subject   st: Re: xpose command
Date   Mon, 3 Mar 2003 19:10:53 -0600

rename c1 _varname
xpose, clear

Scott

----- Original Message ----- 
From: "Don Spady" <[email protected]>
To: "Statalist" <[email protected]>
Sent: Monday, March 03, 2003 6:15 PM
Subject: st: xpose command


> I am having trouble transposing some data.  I do not think this is a
> reshape problem.
> Below are the original data as imported from Excel using StatTransfer.
> In this form it is difficult to determine the effects of various
> treatments
> on the values of the chemicals present.
> 
> If I do xpose, clear varname I get the second table.  Here things
> are in the right order, but the variable names are lost; i.e. where
> do I put in Treatment, Sample, Sodium etc.  I know where to put it, but
> isn't there a way in xpose to do this automatically.
> 
> 
>  c1          c2   c3     c4     c5     c6     c7
> Treat      0       0          1       1       2           2
> Sample  1       2        1       2        1           2
> Na      7.9     7.8     7.2     8.3     16.4     16.4
> K      21.4     20.6     19.1 20.7     19.1     19
> cl      13.4     12.6     12.6 11.6     13     13
> ca      8.6       8.3       8.8     8.8    6.2     6.3
> 
> 
> 
> .xpose, clear varname
> I get this in the editor
> 
>     v1    v2    v3   v4   v5         v6 _varname c1
>                                                         c1
>     0        1     7.9   21.4   13.4    8.6 c2
>     0        2     7.8   20.6   12.6    8.3 c3
>     1        1     7.2    19.1  12.6    8.8 c4
>     1        2      8.3   20.7   11.6    8.8 c5
>     2        1      16.4 19.1    13      6.2 c6
>    2         2      16.4 19       13       6.3 c7
> I have lost the values of the first variable (the na k cl etc)
> 
> THIS IS WHAT I WANT, but I don't want to do it manually.
> 
> treat    Sample      Na    K       cl      ca
> 0            1              7.9   21.4 13.4  8.6
> 0            2               7.8  20.6 12.6  8.3
> 1            1              7.2   19.1 12.6  8.8
> 1            2              8.3   20.7 11.6 8.8
> 2            1             16.4  19.1 13    6.2
>  2          2              16.4  19    13    6.3
> 
> What am I doing wrong? (Besides using Excel as a data sheet)
> 
> Many thanks in advance.
> 
> Donald Spady
> Dep't of Pediatrics, University of Alberta
> (780) 407-1244
> 
> Nature has no reset button.
> 
> 
> *
> *   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/

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index