Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: Need help to create variable from list of qualitative variables


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: Need help to create variable from list of qualitative variables
Date   Mon, 7 Mar 2011 00:28:57 +0000

I don't know what kind of explanation you seek here.

Here is an example. 0 + 0 + 0 + 1 + 1 + 1 = 3. Subtract from 7, and
you get 4. If you want to check this out directly with Stata, use
-display-.

Also, to find out what the -egen- function -rowtotal()- does, look in
the help for -egen- explanation. The name -rowtotal()- is in fact
indicative, meaning "row total" across a varlist.

Alternatively, if you didn't want what these calculations do, please
revise your question.

Nick

On Sun, Mar 6, 2011 at 5:31 PM, prakash singh <[email protected]> wrote:
> Thanks a lot Nick
>
> Nick, if you do not mind can you just give me the hint on reasoning of
> the command.
>
> Prakash
>
> On 3/6/11, Nick Cox <[email protected]> wrote:
>> In fact you might as well go
>>
>> gen myvar = 7 - (var1 + var2 + var3 + var4 + var5 + var6)
>>
>> On Sun, Mar 6, 2011 at 2:23 PM, Nick Cox <[email protected]> wrote:
>>> egen myvar = rowtotal(var1-var6)
>>> replace myvar = 7 - myvar
>>>
>>> Nick
>>>
>>> On Sun, Mar 6, 2011 at 12:39 PM, prakash singh <[email protected]>
>>> wrote:
>>>
>>>> I have six qualitative variable with two options (yes/no) in each
>>>> question. Now, I want to create a variable using these six variable
>>>> such that the new variable will have value equal to one if for all the
>>>> six variables option is yes, then new variable will have value equal
>>>> to two if for any five variables option is yes and no for any one of
>>>> these.... and so on.
>>>
>> *
>> *   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index