Professional Documents
Culture Documents
For instance, given a set of observations of the ages of a group of people, say ranging from 10
years to 61 years. One could desire to categorize the continuous age records into five age groups
such as given below:
This can easily be achieved by using the command egen in combination with the function cut()
as illustrated in the example below.
The following data of age in years for eleven people is captured in Stata and saved in the file
age.dta
10, 20, 21, 30, 31, 40, 41, 50, 51, 60, 61
To view the entered data we open our data file in Stata and tabulate the frequencies as follows:
. use "C:\Users\Andrew\Desktop\age.dta"
Page 1 of 2
. tab age
We then generate a new variable called agegroup and tabulate it using the five groups as follows:
. table agegroup
----------------------
agegroup | Freq.
----------+-----------
10- | 2
21- | 2
31- | 2
41- | 2
51- | 3
----------------------
. tabulate agegroup