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: basic question


From   Eric Booth <[email protected]>
To   "<[email protected]>" <[email protected]>
Subject   Re: st: basic question
Date   Tue, 23 Aug 2011 01:46:34 +0000

<>
Nadine:

You received several, similar answers about your issue.  In addition to all these and the help files for -sum()- and -egen-, take a look at Nick Cox's 2002  article "Speaking Stata: On getting functions to do the work." Stata Journal 2: 411–427. (Free due to SJ's moving pay wall at:  http://www.stata-journal.com/sjpdf.html?articlenum=pr0007 ) 

- Eric
On Aug 22, 2011, at 8:24 PM, Nadine Brooks wrote:

> But it is not what is happening. Take a look:
> 
> sum v9532 v9982 v1022
> 
>    Variable |       Obs        Mean    Std. Dev.       Min        Max
> -------------+--------------------------------------------------------
>       v9532 |    170014    831.5625    1451.442          3     120000
>       v9982 |      8326    686.3957    1179.807          1      48000
>       v1022 |       672      957.75    1422.576          8      11000
> 
> . gen sal= (v9532+v9982+v1022)
> (409603 missing values generated)
> 
> . sum v9532 v9982 v1022 sal
> 
>    Variable |       Obs        Mean    Std. Dev.       Min        Max
> -------------+--------------------------------------------------------
>       v9532 |    170014    831.5625    1451.442          3     120000
>       v9982 |      8326    686.3957    1179.807          1      48000
>       v1022 |       672      957.75    1422.576          8      11000
>           sal |       638    3999.621    4536.377         68      40000
> 
> 
> My variables meas:
> 
> v9532: income from main job
> v9982: income from secondary job
> v1022: third or more of income jobs
> 
> But most of the people have only one job, so they get missing to v9982
> and v1022...
> 
> Thanks, Nadine
> 
> 
> 2011/8/22 Daniel Marcelino <[email protected]>:
>> Well, I don't know exactly what yours variables means.
>> If you have numeric values, you result should be:
>> v1 v2 v3  sal
>> 1   2   3    6
>> 1   .    1    2
>> 
>> 
>> Daniel
>> 
>> On Mon, Aug 22, 2011 at 9:11 PM, Nadine Brooks <[email protected]> wrote:
>>> By there are missing values particularlly in v9102 and v1022, so I
>>> think that I can not use the operator +, can I?
>>> 
>>> 
>>> 
>>> 2011/8/22 Daniel Marcelino <[email protected]>:
>>>> try
>>>> 
>>>> gen sal= (v9535 + v9102 + v1022)
>>>> 
>>>> Daniel
>>>> 
>>>> 
>>>> On Mon, Aug 22, 2011 at 8:54 PM, Nadine Brooks <[email protected]> wrote:
>>>>> Hi statalist
>>>>> 
>>>>> I am a beginner Stata user and I am having trouble to generate a new
>>>>> variable. I am using:
>>>>> gen sal=sum (v9535,v9102,v1022)
>>>>> and I am getting: v9535,v9102,v1022 invalid name
>>>>> r(198);
>>>>> 
>>>>> But the names of all the variables are correct, so what I am doing wrong?
>>>>> 
>>>>> Thanks
>>>>> *
>>>>> *   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/
>>>>> 
>>>> 
>>>> 
>>>> 
>>>> --
>>>> About me: http://danielmarcelino.zip.net/
>>>> 
>>>> *
>>>> *   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/
>>> 
>> 
>> 
>> 
>> --
>> About me: http://danielmarcelino.zip.net/
>> 
>> *
>> *   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