Ado-files: check and install automatically

If you need a certain ado-file to run your do-file and you are working on different computers, there is a way that Stata checks whether the needed ado-files are installed and that needed ado-files are automatically installed if they are not yet on the computer. Simply paste this code in the header of your do-file (here, I need ado-packages ranktest and ivreg2):

foreach package in ranktest ivreg2 {
capture which `package'
if _rc==111 ssc install `package'
}

Leave a Reply