****************************************************************************** * Assignment 1 * BE SURE TO TYPE ALL COMMANDS YOU USE IN THIS DO FILE FOR FULL * CREDIT. Write out the answers to the questions after the word "ANSWER:" in the * question prompts * Submit on the CLE by 1 pm on 8/4/20 * There are 14 questions worth a total of 25 points in this assignment * 2-point questions require a line of code plus an answer for full credit * 1-point questions require either just an answer or just a line of code for full credit * _Your Name_ ****************************************************************************** *SETTING UP* /* A working directory is an address to where your files are stored. Specifing working address in your .do file allows you to access files and data seamlessly every time you open run your .do file Windows uses \ to deliminate paths Mac uses / */ pwd // pwd stands for 'print working directory.' use it to check the current working directory. /* Now let's change the working directory to where you'd like to save your homework files. Create a file in the location of your choice; then copy the path name of the file to change the working directory, or use the drop-down menu option. Be sure to replace the pathname I listed below with your own: */ cd "/Users/amandairish/Desktop/Biostat 212/Week 1" clear //clear any open data sets /* Stata can record your session into a file called a log file. A log file records both commands and output. Stata will not start a log automatically; you must tell Stata to record your session. Logs are recorded in a format called Stata Markup and Control Language (SMCL). The file can be printed or converted to plain text for incorporation into documents you create with your word processor. Stata log files can also be saved as .log to be opened in any text editor */ capture log close //close any open log files. log using biostat212_hw1.smcl, replace * the "replace" option will save over the existing log file of the same name, if it exists * recall that the "append" option will add-on to the existing log file with same name if you have one /* Immediate commands Answer the following questions using immediate commands. Please round your answer to 2 decimal places if applicable. Hint: you call immediate commands for math in Stata using "display" or "di" for short */ /*** QUESTION 1: (2pt) What is 209/16? ANSWER: */ /* QUESTION 2: (2pt) What is the square root of 1054? ANSWER: */ /* QUESTION 3: (2pt) What is 42 cubed? ANSWER: */ ****************************************************************************** /* Opening a data set Start by opening one of Stata's built-in data sets. Check out the data that comes loaded into Stata with this command: ***/ help dta_examples /* QUESTION 4: (1pt) A description of the datasets can be found here: http://www.stata.com/manuals13/u1.pdf The command "sysuse" loads one of these built in data sets. Now, load the cancer.dta dataset and write the command you used to load it below: */ ****************************************************************************** /* Exploring a data set: the basics */ /* QUESTION 5: (2pt) Start browsing the data set with the command "browse". How many study participants are there? (hint: there is one participant per row) ANSWER: */ /* A quicker way to get the number of participants (or obervations we might say) is using the "describe" command. Try it out here: */ /* QUESTION 6: (2pt) How many variables are there (columns)? (hint: describe can help you here too) ANSWER: */ /* QUESTION 7: (2pt) How many study participants died? (Hint: "codebook died" tells you that 1 means the patient died, 0 means they are alive) ANSWER: */ /* Tabulate (tab for short) gives you tabulations for categorical variables. You can create 2x2 tables or cross-tabulations for 2 categorical variables. Here is an example: */ tab drug died /* You can get row or column percentages by adding the ",row" or ",col" option: */ tab drug died, row /* QUESTION 8: (1pt) What percentage of study particpants in the placebo drug group died? (1pt) ANSWER: */ /* QUESTION 9: (2pt) Of the study particpants who died, what percentage were in the placebo drug group? (Hint: looking at the percentages by column will help here) ANSWER: */ /* QUESTION 10: (2pt) What is the average (mean) age? (Hint: use the "summarize" (sum for short) command) ANSWER: */ /* QUESTION 11: (1pt) How old is the youngest person in the data set? (Hint: sum is helpful here too) ANSWER: */ /* QUESTION 12: (2 pt) What is the median age? (Hint: try codebook instead of summarize) ANSWER: */ /* QUESTION 13: (2pt) How many study participants have missing data for the amount of time under observation? (Hint: check the "studytime" variable) ANSWER: */ log close /* QUESTION 14: (2pts) Save your do-file, and upload your do-file and log file to the CLE website. The do-file should be capable of running in its entirety without errors (i.e. no error messages noted on your log file). */