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: Using Percent of another variable to gen new var


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Using Percent of another variable to gen new var
Date   Mon, 25 Jul 2011 14:53:31 +0100

This question was answerd last week. See

http://www.stata.com/statalist/archive/2011-07/msg00720.html

On Mon, Jul 25, 2011 at 2:30 PM, Jonathan Grondin
<jomatrix65@hotmail.com> wrote:
> Stata/MP 10.1 for Windows
>
>
>
> Hi there,
>
> I have a questionnaire answered by two groups (group "a" and group "b") of which, every question can be answered by a value of 1 through 5. Every question is divided into 2 variables; e.g. "q5a" & q5b"
>
> For every question, I wish to keep the frequencies of one group but hold as values the Percent (proportions) of the other group.
> e.g. 12 students in group "a" have answered "1" to question five. In group "b", 22 students out of 186 have answered "1" to the same question. Thus, newvar_q5a would have a Freq. of "12" for a value of "11.83" (22/186).
>
> Here is a tabulate of the two groups to explain better my need. Following, I have provided an example of a variable I would like to generate.
>
>
> . tab  q5a
>
>        q5a |      Freq.     Percent        Cum.
> ------------+-----------------------------------
>           1 |         12       *         *
>           2 |         72       *         *
>           3 |         29       *         *
>           4 |         22       *         *
>           5 |         67       *         *
>
> ------------+-----------------------------------
>       Total |        202      100.00
>
>
> . tab  q5b
>
>       q5b |      Freq.     Percent        Cum.
> ------------+-----------------------------------
>           1 |         22        *       *
>           3 |        109        *       *
>           4 |         37        *       *
>           5 |         18        *       *
>
> ------------+-----------------------------------
>       Total |        186       100.00
>
>
>
> I would like to do something like this for all variables but hold numerical values (11.83 and not 22/186)
>
>
>
> . tab  newvar_q5a
>
>        q5a |      Freq.     Percent        Cum.
> ------------+-----------------------------------
>      22/186 |         12        *       *
>           0 |         72        *       *
>     109/186 |         29        *       *
>      37/186 |         22        *       *
>      18/186 |         67        *       *
>
> ------------+-----------------------------------
>       Total |        202      100.00
>
>
> Any suggestions ?
>
> Thank you so much
>
>
> Jonathan
> *
> *   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