Statalist The Stata Listserver


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

st: Matrix? Stack? Reshape? Xpose?


From   buddyb <[email protected]>
To   [email protected]
Subject   st: Matrix? Stack? Reshape? Xpose?
Date   Thu, 22 Jun 2006 09:11:13 -0700 (PDT)

Maybe let me explain what I need like this...

Currently I have 5 respondents and 3 variables (apple,
pear, oarnge) coded as 1 2 3 .  My data set looks like
this:
           
      ID       apple     pear      orange
      1           2       3          1
      2           1       2          3
      3           2       2          3
      4           3       1          3
      5           3       1          1


What I want to do is to sort of transpose this so that
I would get the following data table so that it adds
up how many 1s 2s and 3s that each of my variables
(apple, pear and oarnge) received:

                   1        2        3
          
         apple     1        2        2
         pear      2        2        1
         orange    2        0        3


Any ideas on what this is called or how to do it?

Thanks, Buddy




--- "White, Justin" <[email protected]> wrote:

> I would check out the gen command and use the by
> option.  I am not sure
> how your data is "shaped".  You may need to reshape
> the data in order
> for my advice to work.  I am assuming you want 1
> variable.
> 
> You could use this:
> Assume there is a variable called fruit_type (apple,
> orange, and pear)
> and a variable called score (which would have the
> low, med, and high)
> 
> By fruit_type: gen fruit = score
> 
> Hope this helps.
> 
> Justin White
> 
> 
> 
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On
> Behalf Of buddyb
> Sent: Thursday, June 22, 2006 10:59 AM
> To: [email protected]
> Subject: 
> 
> Hello everyone,
> 
> I am running STATA 8.  I am not sure what this
> procedure is called, but this is what I am trying to
> do:
> 
> For an example, I have 3 questions asking
> respondents
> to rate how much they like various fruits (Orange,
> Apple, Pear) on a scale of low med high.  So...I
> have
> a data table similar to the following:
> 
> 
>                 Low        Medium       High
> Q1. Orange
> 
> 
>                 Low        Medium       High
> Q2. Apple
> 
> 
>                 Low        Medium       High
> Q3. Pear
> 
> 
> Now I would like to combine these 3 questions into a
> new variable called Fruit that would look similar
> to:
> 
> 
> Fruit         Low           Medium     High
>      Orange
>      Apple
>      Pear
> 
> Is this possible or does it make sense?
> 
> Thanks,
> Buddy
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam
> protection around 
> http://mail.yahoo.com 
> *
> *   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/
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
*
*   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