Hi all. I'm trying to execute a routine over several datasets however, it stops after the first year. The syntax is,
local years 2003 2008 2015
foreach i of local years {
cd "C:/Users/Document/Data/`i'"
use "data`i'.dta"
putmata X=(x1 x2 x3)
mata
X
hh=rows(gzero)
X
hh
w=(1,2,3)
w
X1=X:*w
X1
c=rowsum(X1)
c_md=J(hh,1,0)
for (i=1; i<=rows(c); i++) {
if (c[i,1] >= 3/7) {
c_md[i,1] = 1
}
}
q = colsum(c_md)
end
clear all
Thanks in advance
local years 2003 2008 2015
foreach i of local years {
cd "C:/Users/Document/Data/`i'"
use "data`i'.dta"
putmata X=(x1 x2 x3)
mata
X
hh=rows(gzero)
X
hh
w=(1,2,3)
w
X1=X:*w
X1
c=rowsum(X1)
c_md=J(hh,1,0)
for (i=1; i<=rows(c); i++) {
if (c[i,1] >= 3/7) {
c_md[i,1] = 1
}
}
q = colsum(c_md)
end
clear all
Thanks in advance
Comment