10.04.2013 Views

STATA 11 for Windows SAMPLE SESSION - Food Security Group ...

STATA 11 for Windows SAMPLE SESSION - Food Security Group ...

STATA 11 for Windows SAMPLE SESSION - Food Security Group ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Stata <strong>11</strong> Sample Session Section 3 – Tables and other Types of Analysis<br />

Converting categorical variables to<br />

indicator variables<br />

generate byte age18p = ca3>=18 if ca3 < .<br />

tab1 age18p<br />

Then, any missing values in ca3 would also be missing in<br />

the new variable age18p.<br />

Suppose that you want to do regression analysis and control<br />

<strong>for</strong> effects of the different geographic regions. We have a<br />

variable called district which has 3 categories. We want to<br />

create indicator variables <strong>for</strong> the three districts. These<br />

types of variables are also called dummy variables. First<br />

let’s run the describe command to look at the contents of<br />

the file:<br />

describe<br />

Next let’s look at the values and labels <strong>for</strong> the variable<br />

district:<br />

label list district<br />

To make 3 indicator variables we can type:<br />

tabulate district, generate(district)<br />

Now, run the describe command again:<br />

describe<br />

Three new variables have been created, called district1,<br />

district2, and district3. We can examine the variables using<br />

the tab1 command.<br />

tab1 district*<br />

The variables district1, district2, and district3 can now be<br />

used <strong>for</strong> regression analysis as dummy variables. They<br />

contain either a 0 or a 1.<br />

101

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!