/* This do-file loads a Stata-format dataset, generates a new variable, makes a graph, and saves the new dataset. The file also includes commands to make your interactions with Stata easier (hopefully). */ *comments are denoted with an asterisk or with the slash and asterisk #delimit; *tells Stata that a semicolon denotes the end of a line ; *allows for multi-line commands; *note: don’t use semicolons directly in the command window; clear; *clears any existing data from memory; capture log close; *verifies that any log file is closed; cd C:\mathcamp; *changes the directory to your own (you need to modify); set memory 100m; *allocates more computer memory to Stata; set more off; *allows the program to keep running if output exceeds a page; log using school.log, replace; *creates a log file and saves in in the directory; use school.dta; *opens the file from the current directory; describe; *lists the variables and their types; codebook; *provides summary statistics for each variable; sort read; *sorts data in ascending order according to the variable; count if prgtype=="vocati"; *counts number of vocational program students; display 5+3; *calculates 5+3; mean read; *gives the average reading score; summarize science; *shows summary statistics; generate newscience = science+10; *creates a new variable which is the score + 10; summarize newscience; *shows summary statistics for the new variable; graph twoway scatter read math; *creates a scatterplot; sort prgtype; *sorts the observations, a prerequise for the by command; by prgtype: summarize newscience; *for each program type, give mean reading score; correlate read math; *show the correlation coefficient between reading and math; save newschool.dta, replace; *saves a new version of the dataset, overwriting the old; log close; *closes the log file;