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

# Re: st: how to get monthly values from Bimonthly data

 From Nick Cox To statalist@hsphsun2.harvard.edu Subject Re: st: how to get monthly values from Bimonthly data Date Tue, 31 Jul 2012 13:00:11 -0500

```That wasn't clear.

So, you will need to double up. If monthly dates go up in steps of 2

expand 2
bysort date : replace date = date + 1 if _n == 2

On Tue, Jul 31, 2012 at 12:45 PM, sabbas gidarokostas
> thanks Nick for your reply and the useful code. But I need to convert
> these values to monthly data because the rest of my data are only
> monthly  values.
>
> cheers
>
> On 7/31/12, Nick Cox <njcoxstata@gmail.com> wrote:
>> I would leave these data almost as they are. What you can do is
>>
>> gen year = real(substr(dates, -4, 4))
>> gen period = substr(dates, 1, 2)
>> gen month = cond(per == "JF", 1, cond(per == "MA", 3, cond(per ==
>> "MJ", 5, cond(per == "JA", 7, cond(per == "SO", 9, cond(per == "ND",
>> 11, .))))))
>>
>> gen date = ym(year, month)
>> tsset id date , delta(2)
>>
>> The key point is that you have bimonthly data and that's fine. No
>> doubling up or interpolation is needed; in fact that can only produce
>> a spurious increase in your sample size.
>>
>> Some people would undoubtedly prefer -recode- for the mapping "JF" -> 1,
>> etc.
>>
>> Nick
>>
>> On Fri, Jul 27, 2012 at 3:48 AM, sabbas gidarokostas
>>> Dear all,
>>>
>>> I have the following panel data set
>>> clear all
>>> input str8  (id        text             dates           values1
>>> values2 )
>>>
>>> "1"    "ot"            " "             ""                " "
>>> "1"    "wt"          " "               ""              " "
>>> "1"    "rt"        "MA 2005"            "32.4"          "2.5"
>>> "1"    "gh"        "MJ 2005"            "82.3"          "12.5"
>>> "1"    "bg"        "JA 2005"            "2.5"          "24.5"
>>> "1"    "se"        "SO 2005"            "82.5"          " "
>>> "1"    "cv"        "ND 2005"            "62.3"          "26.3"
>>> "1"    "cv"        "JF 2006"           "12.2"           "22.3"
>>> "1"    "cv"        "MA 2006"            "22.1"          "2.4"
>>> "2"    "ot"          " "                " "               " "
>>> "2"    "wt"           " "                " "         " "
>>> "2"    "rt"        "MA 2005"
>>> "2"    "gh"         "MJ 2005"            "32.3"          "23.5"
>>> "2"    "bg"        "JA 2005"            "52.4"          "22.3"
>>> "2"    "se"        "SO 2005"            "82.9"          "22.5"
>>> "2"    "cv"        "ND 2005"            " "          "2.5"
>>> "2"    "cv"        "JF 2006"            "332.4"          " "
>>> "2"    "cv"        "MA 2006"            "312.4"          "21.5"
>>> end
>>> The above data set is a sample.
>>> Basically,I have 30000 individuals and  instead of the last 2 columns
>>> that contain the numbers I have 29 such columns.
>>>
>>> The data set refers to bimontly values.
>>>
>>> Is there a way to  convert the above data to montly data?
>>> Specifically, What I think is that first I have to split the dates as
>>> follows
>>>
>>> M/2005
>>> A/2005
>>> M/2005
>>> J/2005
>>>
>>> and so forth and then to convert them to
>>>
>>> 3/2005
>>> 4/2005
>>> 6/2005
>>> and so forth.
>>>
>>> So regarding the first 3 columns I should get
>>>
>>> "1"    "ot"            " "
>>> "1"    "wt"          " "
>>> "1"    "rt"        "3/2005"
>>> "1"    "rt"        "4 2005"
>>> "1"    "gh"        "5/2005"
>>> "1"    "gh"        "6/2005"
>>>
>>> and so forth.I am not exactly sure how to handle the last two columns,
>>> though(numerical values)
>>>
>>> I think that one way would be to divide the bimonthly values by 2. Then I
>>> get
>>>
>>> "1"    "ot"            " "
>>> "1"    "wt"          " "
>>> "1"    "rt"        "3/2005"            "32.4/2"          "2.5/2"
>>> "1"    "rt"        "4 2005"              "32.4/2"          "2.5/2"
>>> "1"    "gh"        "5/2005"             "82.3/5"          "12.5/5"
>>> "1"    "gh"        "6/2005"                  "82.3/5"          "12.5/5"
>>>
>>> I am not sure that this makes sense as I have repeated values for two
>>> consequtive months.
>>>
>>> Another way would be interpolation?
>>>
>>> Any code provided is greatly appreciated.
>> *
>> *   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/
```