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: adding a new variable to a dataset


From   Fernando Rios Avila <[email protected]>
To   [email protected]
Subject   Re: st: adding a new variable to a dataset
Date   Wed, 19 Mar 2014 14:00:41 -0400

If the unemployment rate comes from an external file, -merge- is the
best option.
If unemployment rate is estimated using the dataitself, you should
look into -bysort month year region: egen -
Fernando

On Wed, Mar 19, 2014 at 1:55 PM, Nick Cox <[email protected]> wrote:
> Sounds like a -merge-.
>
> Nick
> [email protected]
>
>
> On 19 March 2014 17:52, Jean Sepulveda <[email protected]> wrote:
>> Dear Statalisters,
>>
>> I have the following problem.  Have a dataset with the unit of
>> interest being a person (about 10 million observations). Each person
>> has associated the variables, among many others, month, year and
>> region. Thus for every month, year and region of the country there are
>> thousands of observations of different people.
>> I now want to add a new column with the variable unemployment_rate.
>> This rate varies each month for each region, but does not vary among
>> individuals during a particular month-year-region triplet.
>>
>> I have been adding the observations of the new variable in a manual
>> way like this:
>>
>> gen unemploy=3.3 if month==1 & year==2010 & region==1
>> replace unemploy=4.2 if month==2 & year==2010 & region==1
>> replace unemploy=5.2 if month==3 & year==2010 & region==1
>>
>> and so on. There are 16 different regions, and 3 years of monthly data.
>>
>> Do you know of a faster way to do this?
>>
>> I would appreciate any help,
>>
>> Regards
>> *
>> *   For searches and help try:
>> *   http://www.stata.com/help.cgi?search
>> *   http://www.stata.com/support/faqs/resources/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/faqs/resources/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/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index