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


From   Jean Sepulveda <[email protected]>
To   [email protected]
Subject   Re: st: RE: adding a new variable to a dataset
Date   Wed, 19 Mar 2014 17:00:39 -0300

Thanks a lot Joe and the other helpers.
It works.

regards,

jsu

On Wed, Mar 19, 2014 at 2:57 PM, Joe Canner <[email protected]> wrote:
> Jean,
>
> If you have the unemployment data in a separate data set (or can easily get it into one), what you want is a simple merge:
>
> use persondata, clear
> merge m:1 region year month using unemployment.dta
>
> Regards,
> Joe Canner
> Johns Hopkins University School of Medicine
>
> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On Behalf Of Jean Sepulveda
> Sent: Wednesday, March 19, 2014 1:53 PM
> To: [email protected]
> Subject: st: adding a new variable to a dataset
>
> 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