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: How to Define MDY Variable Given Separate Y and MD Variables
From
Muhammad Anees <[email protected]>
To
[email protected]
Subject
Re: st: How to Define MDY Variable Given Separate Y and MD Variables
Date
Mon, 30 May 2011 15:22:29 +0500
Nick you are right. You suggestion has worked fantatstically out for
me. Sorry for not clarifying my statement which could be as the
Date-Month variable have values like date-month.
On 30 May 2011 14:30, Nick Cox <[email protected]> wrote:
> I understand that holidays are different, but I don't understand what
> you want precisely other than your first sentence. But getting a
> single date variable follows from the principles explained in -help
> dates_and_times-.
>
> Your example cannot be literal, as Stata would not allow the variable
> name -date-month- with an embedded hyphen. I will guess at an
> underscore, that your -date_month- variable is string, and that your
> -year- variable is numeric, in which case try something like
>
> gen date = date(day_month + string(year), "DMY")
> format date %td_d_m_CY
>
> What the data look like is secondary; use -describe- in such questions
> to tell us what they are, especially if this is not enough advice.
>
> Nick
>
> On Mon, May 30, 2011 at 9:44 AM, Muhammad Anees <[email protected]> wrote:
>
>> I have been trying to define a singe data variable from the given two
>> date variables named YEAR and DATE-MONTH for data from from Jan 01,
>> 2005 to Dec 31, 2010. Also the month variable has breaks for holidays.
>> I need to merge the two variable so I could define the yearly specific
>> date with month to compare trends of stocks across the years.
>>
>> The data looks like
>>
>> . li year day-month in 1/20
>>
>> +-----------------+
>> year day-month
>> -----------------
>> 1. 2010 31-Dec
>> 2. 2010 30-Dec
>> 3. 2010 29-Dec
>> 4. 2010 28-Dec
>> 5. 2010 27-Dec
>> -----------------
>> 6. 2010 24-Dec
>> 7. 2010 23-Dec
>> 8. 2010 22-Dec
>> 9. 2010 21-Dec
>> 10. 2010 20-Dec
>> -----------------
>> 11. 2010 15-Dec
>> 12. 2010 14-Dec
>> 13. 2010 13-Dec
>> 14. 2010 10-Dec
>> 15. 2010 09-Dec
>> -----------------
>> 16. 2010 08-Dec
>> 17. 2010 07-Dec
>> 18. 2010 06-Dec
>> 19. 2010 03-Dec
>> 20. 2010 02-Dec
>> +-----------------+
>>
>
> *
> * 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/
>
--
---
Best,
---------------
Anees
*
* 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/