Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: RE: Use 2 variables to gen 10 new variables


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: RE: Use 2 variables to gen 10 new variables
Date   Fri, 29 Jul 2011 00:49:22 +0100

Could you please show the results of

list X1 X2
list X1 X2, nola

Nick


On Thu, Jul 28, 2011 at 3:59 PM, Jonathan Grondin
<jomatrix65@hotmail.com> wrote:
>
> Here is a tabulate of the two variables X1 and X2 holding each 5 values
>
>
>  tab X1
>        X1 |      Freq.     Percent        Cum.
> ------------+-----------------------------------
>           Y1 |        2       10.53       10.53
>           Y2 |        6       31.58       42.11
>           Y3 |        3       15.79       57.89
>           Y4 |        7       36.84       94.74
>           Y5 |        1        0.05       100
>
> ------------+-----------------------------------
>       Total |        19      100.00
>
>
>  tab X2
>
>        X2 |      Freq.     Percent        Cum.
> ------------+-----------------------------------
>           Y1 |        4       20.00       20.00
>           Y2 |        2       10.00       30.00
>           Y3 |        4       20.00       50.00
>           Y4 |        8       40.00       90.00
>           Y5 |        2       10.00       100
>
> ------------+-----------------------------------
>       Total |        20      100.00
>
>
>
>
> I would like to create 5 variable (Y1 to Y5) holding two values each (from prior X1 and X2)
> e.g.:
>
>
> tab Y1
>
>
>
>        Y1 |      Freq.     Percent        Cum.
>
> ------------+-----------------------------------
>
>           X1|        2       33.33       33.33
>
>           X2|        4       66.67      100.00
>
>
>
> ------------+-----------------------------------
>
>       Total |        6      100.00
>
>
> tab Y2
>
>
>
>
>
>        Y2 |      Freq.     Percent        Cum.
>
>
> ------------+-----------------------------------
>
>
>           X1|        6       75.00       75.00
>
>
>           X2|        2       25.00      100.00
>
>
>
>
>
> ------------+-----------------------------------
>
>
>       Total |        8      100.00
>
> etc.
>
>
> Any suggestions ?
>
>
> Jonathan
>
>
> ----------------------------------------
>> Date: Thu, 28 Jul 2011 15:13:02 +0100
>> Subject: Re: st: RE: Use 2 variables to gen 10 new variables
>> From: njcoxstata@gmail.com
>> To: statalist@hsphsun2.harvard.edu
>>
>> Sorry, but I can't relate your example to a Stata dataset. Rows and
>> columns can't both be Stata variables. Please show your example as
>> produced by a Stata command and show how you are holding the data
>> within Stata.
>>
>> On Thu, Jul 28, 2011 at 2:57 PM, Jonathan Grondin
>> <jomatrix65@hotmail.com> wrote:
>> > Indeed, I'll try to present it less ad hoc.
>> >
>> > Let's see it that way:
>> >
>> > I have 2 variables X1 and X2, each holding 5 values (Y1 to Y5). Instead, I'd like to create 5 variables: Y1 through Y5 holding 2 values (X1 & X2)
>> >
>> >
>> >       Y1     Y2    Y3    Y4    Y5
>> >
>> > X1:    2     6     3     7      1
>> >
>> > X2:    4     2     4     8      2
>> >
>> >
>> > I've taken a look at -contract- but can't manage a simple way of doing it.
>> > Any suggestions ?
>> >
>> >
>> > Jonathan
>> >
>> >
>> >> From: n.j.cox@durham.ac.uk
>> >> To: statalist@hsphsun2.harvard.edu
>> >> Date: Wed, 27 Jul 2011 19:15:19 +0100
>> >> Subject: st: RE: Use 2 variables to gen 10  new variables
>> >>
>> >> This sounds very ad hoc. Consider instead the possibilities for producing new reduced datasets by -contract- and -collapse-.
>> >>
>> >> Nick
>> >> n.j.cox@durham.ac.uk
>> >>
>> >> Jonathan Grondin
>> >>
>> >> I have a questionnaire answered by two groups (group "a" and group "b").
>> >> Every question had to be answered by a value of 1 through 10. Every question is then divided into 2 variables, e.g Question 1: "q1a" and "q1b".
>> >>
>> >> I would like to combine q1a and q1b together and create 10 variables out of them each of them holding the frequency of the two groups. e.g. "q1a" and "q1b" would generate: "new_q1_1" to "new_q1_10".
>> >> Every new variable would hold two values: new_q1_1 would hold the frequency of people in group "a" who answered "1" and the frequency of people in group "b" who answered "1".
>> >>
>> >>
>>
>> *
>> * For searches and help try:
>> * http://www.stata.com/help.cgi?search
>> * http://www.stata.com/support/statalist/faq
>> * http://www.ats.ucla.edu/stat/stata/
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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   |   Site index