Professional Documents
Culture Documents
Stata 3 Question
Stata 3 Question
Stata 3 Question
use pop2000, the sysuse pop2000 works better as this is a data set built in in
stata
2. Create new variables.
a. Generate a variable to capture the string length for each observation. Hint: Look
for the appropriate “string function” using the help command. How frequently
does the mode of string length occur? [1 mark]
3. Visualize results.
a. Make a single graph with bars showing female population in millions for each age
group. Your graph should have the following characteristics:
After running the CHATGPT command for the bar graph, this is what is produced,
which we can see is clearly wrong.
a
rks]
After running the correct commands we were able to get this graph bar after
making changes to what ChatGpt had tried to do.
b. Produce a single graph containing both populations in millions for age-groups for
both males and females. Hint: To avoid overlap, make the male population in
millions negative. Export your graph as a png file and paste below. [2 marks]
The variable name was too long in what chatgpt tried to use and the graph was
incorrect.
c. Generate a new variable called zero which only takes the value of 0.
gen zero = 0
After correcting CHATGPT’s command, we were able to get this bar graph.
4. Replicate
a. Create a fully functional DO file of all the commands used in this exercise. Your
DO file should include group number, names of members, date, title, and
comments for each command so that it can be easily read by others. [4 marks]
Have fun!