Just to corrent my awkward syntax here:
preserve
set obs 200 // if obs <200
local var1lbl "all the vavalues of country"
local var2lbl "all the values of year"
gen country=.
gen year=.
gen cntvar3=.
local i = 1
foreach var1val in `var1lbl' {
foreach var2val in `var2lbl' {
replace country = `var1val' if _n =`i'
replace year = `var2val' if _n=`i'
count var3
replace cntvar3 = r(N) if _n=`i'
local ++i
}
}
keep if _n<=200
keep country year cntvar3
save whereever
restore
--------------------------------------------------------