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

# Re: st: Creating Seasonal Dummy Variables

 From Christopher Baum <[email protected]> To "[email protected]" <[email protected]> Subject Re: st: Creating Seasonal Dummy Variables Date Tue, 22 Apr 2014 13:05:13 +0000

```<>

clear
set obs 168
// arbitrary starting point in Stata's calendar
g mo = 119 + _n
format mo %tm
tsset mo, monthly
g seas = month(dofm(mo))
// don't need seasonal dummies to use seas
g junk = runiform()
reg junk ibn.seas, noco hascons
// but if you really want them...
tab seas, gen(M)
reg junk M*, noco hascons

On Apr 22, 2014, at 2:33 AM, Adam wrote:

> 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.

Kit Baum
Professor of Economics and Social Work, Boston College, Chestnut Hill MA, USA
DIW Research Professor, Department of Macroeconomics, DIW Berlin, Berlin, Germany
[email protected]  |  http://ideas.repec.org/e/pba1.html

*
*   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/
```