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: converting weekly to monthly data


From   Stef Salvez <loggyedy@googlemail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: converting weekly to monthly data
Date   Thu, 28 Jun 2012 22:22:05 +0100

Ooops! just a small correction in the data:


In my case I have the prices for 2 goods A and B. The prices are
broken down by the pack size represented by id
(id takes 2 values as there are 2 kind of sizes).

An example is the following


clear all

input str8  (dates1)          priceA   PriceB                    id
 "23/11/08"                          0.5637    0.6034               1
 "28/12/08"                             2           3                   1
 "25/01/09"                           3             4                  1
 "22/02/09"                             3            1                  1
 "29/03/09"                            5              6                  1
 "26/04/09"                             7               7                  1
 "24/05/09"                             1                 5                  1
 "28/06/09"                               1              4                  1
 "26/07/09"                               2              5                  1
 "23/08/09"                            5                   8                   1
 "27/09/09"                              5              6                  1
 "25/10/09"                            4               6                  1
 "22/11/09"                            2                1                  1
 "03/01/10"                            2                4                  1
 "31/01/10"                            1                7                  1
 "28/02/10"                            6                 3                  1
 "23/11/08"                         4                   6                    2
 "28/12/08"                            2           3                    2
 "25/01/09"                            3             4                    2
 "22/02/09"                             3            1                    2
 "29/03/09"                            3             4                    2
 "26/04/09"                             7               7                    2
 "24/05/09"                             1                 5               2
 "28/06/09"                               1              4                2
 "26/07/09"                               6             5                2
 "23/08/09"                            5                   8             2
 "27/09/09"                             6              6                    2
 "25/10/09"                            4               6                    2
 "22/11/09"                           2                1                    2
 "03/01/10"                             2               3                    2
 "31/01/10"                            1                7                    2
 "28/02/10"                            6                 1                  2

end

Each value represents a 4-week average (28 days). However, some values
represent a 5 week average (35) .

You can see that  from



gen dd = date(dates1, "DM20Y")
gen dd2 = dd - dd[_n-1]


So, in my case using

 gen daily=dofw(tw)

format daily %td

gen monthly=mofd(td)

format monthly %tm

makes no sense because these observations are not weekly but 4 or 5
week averages.

My though is to convert these values to daily and then to monthly.
Practically i do not know how to do that.

Is there any way to achieve that?

Kinds regards

On 6/28/12, Stef Salvez <loggyedy@googlemail.com> wrote:
> In my case I have the prices for 2 goods A and B. The prices are
> broken down by the pack size represented by id
> (id takes 2 values as there are 2 kind of sizes).
>
> An example is the following
>
>
> clear all
>
> input str8  (dates1)          priceA   PriceB                    id
>  "23/11/08"                          0.5637    0.6034               1
>   "28/12/08"                             2           3                   1
>   "25/01/09"                           3             4                  1
>   "22/02/09"                             3            1                  1
>  "29/03/09"                            5              6                  1
>  "26/04/09"                             7               7
> 1
>  "24/05/09"                             1                 5
> 1
>  "28/06/09"                               1              4
> 1
>  "26/07/09"                               2              5
> 1
>  "23/08/09"                            5                   8
>        1
>  "27/09/09"                              5              6
> 1
>  "25/10/09"                            4               6                  1
>   "22/11/09"                            2                1
> 1
>  "03/01/10"                            2                4
> 1
>  "31/01/10"                            1                7
> 1
>  "28/02/10"                            6                 3
> 1
>  "23/11/08"                         4                   6
> 2
>   "28/12/08"                            2           3                    2
>   "25/01/09"                            3             4
> 2
>   "22/02/09"                             3            1
> 2
>  "29/03/09"                            3             4                    2
>  "26/04/09"                             7               7
> 2
>  "24/05/09"                             1                 5
>         2
>   "28/06/09"                               1              4
>         2
>   "26/07/09"                               6             5
>        2
>   "23/08/09"                            5                   8
>           2
>  "27/09/09"                             6              6
> 2
>  "25/10/09"                            4               6
> 2
>  "22/11/09"                           2                1
> 2
>  "03/01/10"                             2               3
> 2
>  "31/01/10"                            1                7
> 2
>   "28/02/10"                            6                 1
>         2
>
> end
>
> Each value represents a 4-week average (28 days). However, some values
> represent a 5 week average (35) .
>
> You can see that  from
>
>
>
> gen dd = date(dates1, "DM20Y")
> gen dd2 = dd - dd[_n-1]
>
>
> So, in my case using
>
>  gen daily=dofw(tw)
>
> format daily %td
>
> gen monthly=mofd(td)
>
> format monthly %tm
>
> makes no sense because these observations are not weekly but 4 or 5
> week averages.
>
> My though is to convert these values to daily and then to monthly.
> Practically i do not know how to do that.
>
> Is there any way to achieve that?
>
> Kinds regards
>
>
>
> On 6/28/12, Sarah Edgington <sedging@ucla.edu> wrote:
>> .
>> Well, if you don't know what you've done wrong, we certainly have no way
>> of
>> knowing. You haven't shown us what you did or how it's "not working."
>> Try reading the statalist FAQ.
>> http://www.stata.com/support/faqs/resources/statalist-faq/
>> Section 3 is particularly useful for figuring out how to formulate
>> questions
>> in a way that will increase your chances of getting a helpful answer.
>> Good luck.
>> -Sarah
>>
>> -----Original Message-----
>> From: owner-statalist@hsphsun2.harvard.edu
>> [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of j maleii
>> Sent: Thursday, June 28, 2012 1:03 PM
>> To: statalist@hsphsun2.harvard.edu
>> Subject: RE: st: converting weekly to monthly data
>>
>>
>> sorry guys not working. i dont know what ihave done wrong
>>
>>
>> *
>> *   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