Using STATA
Workflow and File Management
Here’s a quick workflow for starting a new project, which incorporates the key ideas of reproducible research using Stata:
Create a new folder with name
peco-4980-thesis
.Open your text editor or Stata and create a new do file. Name it
000-setup-mac.do
to prepare the project directories. Or you can download the same file from here and paste it in the folder.Save and run the do file within Stata to set up your project directories. Code below is just for review from the same do file.
```{stata}
* Define the base project directory | According to your system
global project_dir "/path/to/your/project/directory"
* Function to create directories
cap program drop create_folder
program define create_folder
args folder_path
if !fileexists("`folder_path'") {
mkdir "`folder_path'"
}
end
* Create Main Folders
create_folder "$project_dir/Data"
create_folder "$project_dir/Data/Raw"
create_folder "$project_dir/Data/Clean"
create_folder "$project_dir/Scripts"
create_folder "$project_dir/Scripts/Stata-Scripts"
create_folder "$project_dir/Outputs"
create_folder "$project_dir/Outputs/Figures"
create_folder "$project_dir/Outputs/Tables"
create_folder "$project_dir/Outputs/Text"
* Print confirmation message
di "Project directory and subfolders have been created successfully."
```
- Save your raw datasets in
..Data/Raw
folder.
Variable Creation and Merging Datasets
Use the file here with apporpriate modifications.