I'm recreating a study for my final project and I'm using the code the economists used in the study but I keep getting the r198 error. The code is below. Does anyone know what's causing this and how to fix it?

* --------------------------------------------------------------------------- *

* MAKES QUARTERLY TIME SERIES OF HOURS PER WORKER IN PART-TIME AND FULL-TIME

* INDIVIDUALS IN PRIVATE-SECTOR PAID EMPLOYMENT

/*

SERIES 1 - WORKING AGE

SERIES 2 - PRIME AGE

SERIES 3 - WORKING AGE, PT <30 TOTAL USUAL HOURS

SERIES 4 - PRIME AGE, PT <30 TOTAL USUAL HOURS

SERIES 5 - WORKING AGE, SINGLE JOBHOLDERS

SERIES 6 - PRIME AGE, SINGLE JOBHOLDERS

*/

* --------------------------------------------------------------------------- *

set more off
clear all

mata:
void colapsar( )
{
st_view(x=., . , .)
st_subview(w=.,x,.,1)
st_addobs(1,)
y=rows(x)+1
st_view(z=.,y,.)
z[.,.]=w'*x
}
end

// replace DIR by the path of your working directory

cd "C:\Users\johnd\Documents\University of Missouri\Research\Original Paper Info\data\uk_data"

qui {

forv d = 19934(1)20172 {

cap confirm file lfs1q_`d'.dta

if !_rc {

use lfs1q_`d'.dta, clear

g y = regexs(0) if regexm("`d'","^[0-9][0-9][0-9][0-9]")
g q = regexs(0) if regexm("`d'","[0-9]$")
destring y q
g date =mdy(q*3,1,y)
drop y q

* samples by age
keep if inrange(age,16,64)

// use old uk working-age definition
drop if sex==2 & inrange(age,60,64)

g s_1 = (inrange(age,16,64))
g s_2 = (inrange(age,25,54))

* weights
ren pwt?? pwt
drop if pwt == . | pwt == 0

* economic activity
if inrange(date,mdy(6,1,1992),mdy(3,1,2005)) {
g e = (inecacr==1)
}

if inrange(date,mdy(6,1,2005),mdy(12,1,2017)) {
g e = (inecac05==1)
}

keep if e == 1

* private sector
g g = (publicr==1)

keep if g ==1

* part-time and full-time
g pt_tu_30 = (inrange(ttushr,1.0,29.4))
g pt_tu_35 = (inrange(ttushr,1.0,34.4))
g ft_tu_30 = (inrange(ttushr,29.5,97))
g ft_tu_35 = (inrange(ttushr,34.5,97))

* no second job
g nsj = (secjmbr==5)

* samples by employment sector
g e_1 = s_1*g
g e_1_nsj = e_1*nsj
g e_2 = s_2*g
g e_2_nsj = e_2*nsj

* samples by part-time definition
foreach j in pt_tu_30 pt_tu_35 ft_tu_30 ft_tu_35 {

g e_1_`j' = e_1*`j'
g e_1_nsj_`j' = e_1_nsj*`j'
g e_2_`j' = e_2*`j'
g e_2_nsj_`j' = e_2_nsj*`j'
}

* hours
g h_ta = (inrange(ttachr,0.0,97))

* hours and stocks of workers reporting hours
foreach lm in e_1 e_2 e_1_nsj e_2_nsj {

g `lm'_th_ta = `lm'*h_ta*ttachr
g `lm'_ta = `lm'*h_ta

foreach v of varlist pt_tu_30 pt_tu_35 ft_tu_30 ft_tu_35 {

g `lm'_`v'_th_ta = `lm'*`v'*h_ta*ttachr
g `lm'_`v'_ta = `lm'*`v'*h_ta
}
}

local y = year(date)
local q = quarter(date)

noi keep pwt e_*

noi disp "qlfs_`d'"
noi count

unab vlist: e_*

replace pwt = pwt/1000
order pwt

mata: colapsar()
count
local last = r(N)
keep in `last'

g y = `y'
g q = `q'

tempfile 1q_`d'
noi save "`1q_`d''"

}
}


clear

g empty = 0

forv d = 19934/20172 {

cap confirm file "`1q_`d''"

if !_rc {

append using "`1q_`d''"

}

}

drop empty
sort y q
g t=_n
tsset t

* compute hours per worker
foreach lm in e_1 e_2 e_1_nsj e_2_nsj {

g `lm'_ah_ta = `lm'_th_ta/`lm'_ta

foreach v in pt_tu_30 ft_tu_30 pt_tu_35 ft_tu_35 {
g `lm'_`v'_ah_ta = `lm'_`v'_th_ta/`lm'_`v'_ta
}
}

* drop stocks of hours questions respondents
foreach lm in e_1 e_2 e_1_nsj e_2_nsj {

drop `lm'_ta `lm'_th_ta

foreach v in pt_tu_30 ft_tu_30 pt_tu_35 ft_tu_35 {
drop `lm'_`v'_ta `lm'_`v'_th_ta
}
}

forval s = 1(1)6 {

preserve

if `s' == 1 {
keep y q t e_1_*
drop e_1_nsj*
ren e_1_* *
drop *30*
ren *pt_tu_35* *p*
ren *ft_tu_35* *f*
do dofiles/uk_code/adjust_hours_quarterly
g s = `s'
tempfile ds_`s'
noi save "`ds_`s''"
}

if `s' == 2 {
keep y q t e_2_*
drop e_2_nsj*
ren e_2_* *
drop *30*
ren *pt_tu_35* *p*
ren *ft_tu_35* *f*
do dofiles/uk_code/adjust_hours_quarterly
g s = `s'
tempfile ds_`s'
noi save "`ds_`s''"
}

if `s' == 3 {
keep y q t e_1_*
drop e_1_nsj*
rename e_1_* *
drop *35*
ren *pt_tu_30* *p*
ren *ft_tu_30* *f*
do dofiles/uk_code/adjust_hours_quarterly
g s = `s'
tempfile ds_`s'
noi save "`ds_`s''"
}

if `s' == 4 {
keep y q t e_2_*
drop e_2_nsj*
rename e_2_* *
drop *35*
ren *pt_tu_30* *p*
ren *ft_tu_30* *f*
do dofiles/uk_code/adjust_hours_quarterly
g s = `s'
tempfile ds_`s'
noi save "`ds_`s''"
}

if `s' == 5 {
keep y q t e_1_nsj_*
ren e_1_nsj_* *
drop *30*
ren *pt_tu_35* *p*
ren *ft_tu_35* *f*
do dofiles/uk_code/adjust_hours_quarterly
g s = `s'
tempfile ds_`s'
noi save "`ds_`s''"
}

if `s' == 6 {
keep y q t e_2_nsj_*
ren e_2_nsj_* *
drop *30*
ren *pt_tu_35* *p*
ren *ft_tu_35* *f*
do dofiles/uk_code/adjust_hours_quarterly
g s = `s'
tempfile ds_`s'
noi save "`ds_`s''"
}

restore
}

use "`ds_1'", clear

forv s = 2(1)6 {

append using "`ds_`s''"
}

lab define series 1 "Working age" 2 "Prime age" 3 "Working age, 30 hours cutoff" 4 "Prime age, 30 hours cutoff" 5 "Working age, single jobholder" 6 "Prime age, single jobholder"

lab val s series

order s t y q

save hours_quarterly, replace

exit

}


---
. qui {
must specify either generate or replace option
r(198);

end of do-file