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
Change legend automatically in graphDear Statalists, Suppose I have a data like this Code: * Example generated by -dataex-. To insta…
New packages available on SSC: comtrade and htmltab2stataThanks two Kit Baum two new packages are available on SSC. comtrade comtrade downloads trade data f…
New packages cprdonsutil and cprdlsoautil on SSCThanks as always to Kit Baum, 2 new packages cprdonsutil and cprdlsoautil are now available for down…
Putting labels for different variables in one line of code or loop?Hello, I would like to add labels for a set of different variables, i have around 15, and would lik…
Test for sufficient sample size in linear probability modelHi, I run the following linear probability model: Code: reg nodad k1sex i.meduc i.state i.mdecade…
Subscribe to:
Post Comments (Atom)
0 Response to Syntax error in loop creation
Post a Comment