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]

st: Creating Seasonal Dummy Variables


From   Adam Guerrero <[email protected]>
To   [email protected]
Subject   st: Creating Seasonal Dummy Variables
Date   Tue, 22 Apr 2014 00:14:17 -0500

Dear Statalisters,

I have a dataset comprised of 168 observations, or 14 years worth of
monthly data, on two variables, rooms and time.  Rooms is the number
of occupied rooms in a hotel during a given month, and time is the
current month ranging from 1 to 168.

The data are time ordered.  So, the first observation in the dataset
represents the first month of the first year, and the 168th
observation in the dataset represents the last month of the last year,
and so on.

My goal is to create eleven seasonal dummy variables, m1-m11.  The
month of December will be used as my reference category.  Thus,

m1 will equal 1 for all January months, so m1 will equal 1 for
observations 1, 13, 25, etc.

m2 will equal 1 for all February months, m2 will equal 1 for
observations 2, 14, 26, etc.

I can write a looping statement to create empty dummies.  For example

forvalues i = 1/11 {
     generate m`i' = 0
}

But, I am experiencing an issue creating a looping command to fill in
each variable with the appropriate values.  Actually, I would like to
combine these tasks, if possible.

I would be very thankful if a member of the statalist community would
be willing to teach me how to create the 11 dummy variables with the
appropriate values (leaving December out as the base case).

I am new to programming, so pardon my current lack of knowledge, and
thank you for your consideration.

Adam A. Guerrero
*
*   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