Hi everyone,
I am getting an error in the loop creation and cannot identify why. Any suggestions would be very appreciated.
use "treated_firms.dta", replace
*Loop for 1974-1980, 1980-1983, 1983-1985
forvalues i = 1/3 {
keep if compare == `i'
global N=_N
forvalue ipocompany = 1/$N {
use "treated_firms.dta", replace
keep if _n==`n'
display `n'
joinby m:m siccd3 date using "control_firms.dta"
keep if _merge == 3
drop _merge
compress
if _N!=0 {
gen n_dist = ((ipo_price_ct - ipo_price_tr)^2)
sort n_dist
keep if _n == 1
drop n_dist_1
}
if `n' > 1 {
append using matched_pairs.dta, nolabel
}
save "matched_pairs.dta", replace
}
}
restore
Thank you !
Related Posts with Syntax error in loop creation
"Outcome does not vary in any group"Hi, I have a balanced panel data comprising 10 independent variables for a period of five years for…
Recode with if does not workHi all, I have the following problem. I am trying to recode values of a variable conditioning on giv…
generating new variable based on date variableDear Stata community, I have a variable stored as dates in the Stata format i.e 01jul1993 (I conver…
Keeping most full observation in a hierarchyHi, I have a dataset that is a hierarchy set over a maximum of 4 levels where each row is a level i…
Using putexcel to enter output from a cross tabulationDear all, Seeking some advice on how to export a specific format of output into Excel, from tabulat…
Subscribe to:
Post Comments (Atom)
0 Response to Syntax error in loop creation
Post a Comment