Jesper Böjeryd

Stata patterns | Jesper Bojeryd

Stata patterns

27 April 2026

There are some Stata patterns I keep having to search on Google over and over. I’ll try to put them here to save myself time.

List all files in a folder with a certain name pattern

local filelist : dir “folder-path” files “name-pattern-*.dta”, respectcase // Without the option, file name will be displayed wrong

foreach file in `filelist’ {
    Here it goes …
}