// Project description: // Created by: // Date created: // Last updated: // This do-file is an example of hwo you could ste up ana analysis of BIS data // each STEP could be saved as a separate do-file if preferred // you can run a do-file from within a do-file using the command: do "dofile_name.do" ******************************************************************************** * STEP 0: Set directories etc. ******************************************************************************** * Set working directories // Locations where any files for this project will be saved // Its easier to type these out only once, at the beginning of the analysis global rawdataloc "C:\Project\Raw data" global analysisloc "C:\Project\Analysis files" global cleandataloc "C:\Project\Clean data" global outputloc "C:\Project\Tables and figures" * Get the current date // This creates a macro with today's date in the format YYYYMMDD global date: display %tdCCYYNNDD date("`c(current_date)'","DMY") ******************************************************************************** * STEP 1: Data cleaning ******************************************************************************** * Create a single, clean dataset for analysis ** Open dataset of demographics/baseline charactersitcs cd "$rawdataloc" use "demographics_data", clear ** Add data from timepoint 1 cd "$rawdataloc" merge 1:1 bisid using "timepoint1_data" // Make sure variable names don't clash with variable names in other datasets // E.g. the date that questionnaire 1 was completed might be called 'date' // This should be renamed to 'date1' so it doesn't clash with the date that questionnaire 2 was completed ** Add data from timepoint 2 cd "$rawdataloc" merge 1:1 bisid using "timepoint2_data" // Insert any other data clenaing steps here // If you need to add additional datasets later on, you can do this here ** Save cleaned data // It's good practice to save this dataset with today's date // This way, if you make any changes to your analysis later on, // you can always come back to a previous version of your data cd "$cleandataloc" save "cleandata_${date}", replace // If you have finalised your data cleaning, you can comment out this // entire STEP using: /* and */ ******************************************************************************** * STEP 2: Analysis ******************************************************************************** ** Open the clean data // You will need to update this with the most up-to-date dataset you have cd "$cleandataloc" use "cleandata_20201009", clear // Perform any analysis steps here ** Save figure // create your graph using e.g. twoway ... cd "$outputloc" graph export "figure1.png", replace // If you need any help setting up your data cleaning or analysis // you can contact james.hedley@mcri.edu.au