December 02, 2003

Stata 5 Notes

Remember to use the command "set memory 10m" before you try to load the big dataset.

To generate a variable hsg that equals 1 for high school graduates and zero otherwise and a variable coll that equals 1 for high school graduates and zero otherwise:

gen hsg = a_hga > 38
gen coll = a_hga > 42
gen educ = hsg+coll
gen age2=a_age*a_age

Notice that educ will be 2 for college graduates, 1 for high school graduates that did not graduate from college, and 0 for those who did not finish high school. This could be useful if you want to study categories of education.

The age2 variable allows the "age-earnings profile" to be a curved line rather than a straight line.

The command

keep if a_age > 20

creates a sample with only people at least 21 years old.

If you save a dataset after using keep and gen to set things up, you can come back to that data later without retyping any commands.

Here is how to do a table of averge income by marital status and gender.

Image1.png

The second tab limits the table to those who worked over 40 weeks and repeats the table of the major occupation groups. To do multiple conditions, use something like "(wkswork > 40) & (a_maritl == 1)". Do not forget that the equality comparison uses two equal signs.

Image2.png

Here is how to run a regression of income on age and age-squared.

Image3.png

Posted by bparke at December 2, 2003 02:29 PM