I am an enthusiast of R fighting for the land of Stat. I encountered the following problem in my attempts to "translate" from R to Stata:
In R, so that my script files do not get too big and crazy, I like to write them in smaller parts, and then have one main R script that is read in smaller ones, for example.
source("script-1.R")
source("script-2.R")
I would like to do the same in Stata and tried to do
do "script-1.do"
do "script-2.do"
However, I find that if I create a macro in script-1.dofor example. local bird 1 An object / macro bird is not available in the main script or available for script-2.do. If I try to display the content birdin the main script, it is just empty.
script-1.do
local bird 1
script-2.do
bird
Why is this? Any tips?
include. include do ( run):
include
do
run
.
Stata : local global. local , ( , do program). - script-1.do, , return, . (Do , program, rclass , program .) global , , .
local
global
program
return
program, rclass
R , Stata . - Stata, . , , Stata - , , R . , , .
, include . "" . , , , scalar, .
scalar