STATA learning step by step

# change the current woring directory to E:\eBooks_STATA # use cd "E:\eBooks STATA" if there is a blank space in the directory cd E:\eBooks_STATA # to see the current working directory pwd # create a log file called logfile.log log using logfile.log # options to log # log using logfile.log, append # log using logfile.log, replace # log close # closes log file # to open STATA file 'Students.dta' use E:\eBooks_STATA\Students.dta use Students.dta # if already in the working directory # description of data set in use describe

# look for key word 'status' in variable names and labels lookfor status # produce a frequency table of the variable 'major' for students age under 30 tabulate major if age < 30 # produce a scatter plot of the variable 'sat' vs the variable 'age' scatter sat age # produce side by side boxplots of the variable 'sat' vs the variable 'gender' (categorical) graph box sat, over(gender) # generate a variable 'case' from 1 to data size n generate case= _n # generate a variable gendercode with default value 0 generate gendercode = 0 # or gen gendercode = 0 # make gendercode = 1 for all Males replace gendercode = 1 if gender == "Male"