How to run ado file in another ado file in Stata?

In R, I can run another R script using

source("script.R") 

How can I do the same in Stata?

+4
source share
1 answer

There are two types of scripts in Stata:

  • There are do-files that are sequences of commands when they are entered that can contain almost anything, and
  • There are ado files that are stand-alone scripts of the program. Ado means "automatically downloaded DO files."

The main difference is that to execute the do file you need to do it or run it:

 do whatever.do 

shows the result, and

 run whatever.do 

suppresses the conclusion.

Automatically downloaded do files, as the name implies, are downloaded automatically. When entering

 blah blah1 blah2 

Stata first looks for the blah program in its memory. If he is not there, he will look for the blah.ado file in the subdirectories identified in his adopath , which by default includes its own Stata directories, as well as the current directory ( adopath type to find out more if you're interested). If he finds this blah.ado , he will (1) make sure that he has program define blah inside it, and (2) try to run this program with any arguments that you provided ( blah1 blah2 ). If he cannot find the blah.ado file anywhere, he gives an error message:

  . blah blah1 blah2 unrecognized command: blah r(199); 
+7
source

All Articles