April 03, 2025 1:00 pm - 3:00 pm ET
Data and Software,
Research Methodology,
Semester Workshops
Online - Zoom link sent upon registration
STATA Logo.

Instructor: Onupurba Das

Ever feel like you’re spending more time repeating lines of code just to get your data right instead of analyzing it? This workshop is here to change that! In this hands-on session, you’ll practice writing loops and using macros to streamline your workflow. 

Loops let you automate repetitive tasks—think running regressions across multiple variables or appending datasets in one go. Macros act as handy placeholders for values, file paths, or commands, saving you time and reducing errors. These tools simplify repetitive tasks, reduce manual coding changes, and make your code more efficient. 

 

Learning Objectives:

  1. Write and use loops (foreach, forvalues) to automate the same repeated tasks in STATA, like running commands across multiple variables or datasets.
  2. Create local and global macros to store values, file paths, and commands that you can reuse throughout your code.
  3. Combine loops and macros to tackle more complicated tasks.
  4. Best practices for debugging and troubleshooting loops in STATA (time permitting).

Pre-requisites/Notes:

  1. Prior STATA experience - some familiarity with do-files and coding data management commands like merge, append and regress etc.
  2. The workshop uses STATA for PC, and there are a few minor commands and functionalities different in STATA for Mac and we will go over those if needed.
  3. Lab computers have STATA access; if using your own laptop, ensure STATA is installed and ready to use.