Good morning, I am now doing a do_file but I noticed that if I run the whole do file I get different(and wrong) results than if I instead run differently 2 parts divided by a clear all. Anyone knows why?
this are my command:
use "C:\Users\tomma\OneDrive\Desktop\s1_1.dta"
merge m:m hhcode using "C:\Users\tomma\OneDrive\Desktop\S9_1.dta", nogenerate
preserve
drop if age_y<5
drop if educ>14
drop if s9_1q1 !=1
oneway educ s9_1q2, scheffe
restore
merge m:m hhcode using "C:\Users\tomma\OneDrive\Desktop\s2_a.dta", nogenerate
preserve
drop if s2q5 != 2
drop if s9_1q1 != 1
drop if s2q10>14
oneway s2q10 s9_1q2, scheffe
restore
preserve
drop if s2q5 != 1
drop if s9_1q1 != 1
drop if s2q14>14
oneway s2q14 s9_1q2, scheffe
restore
merge m:m hhcode using "C:\Users\tomma\OneDrive\Desktop\s2_B.dta", nogenerate
drop if s2q5 != 1
drop if s9_1q1 != 1
drop if s2q24 >14
oneway s2q24 s9_1q2, scheffe
clear all
use "C:\Users\tomma\OneDrive\Desktop\s1_1.dta"
merge m:m hhcode using "C:\Users\tomma\OneDrive\Desktop\S9_1.dta", nogenerate
drop if age_y<5
drop if s9_1q1 != 1
drop if educ>14
preserve
drop if sex!=1
oneway educ s9_1q2, scheffe
restore
drop if sex != 2
oneway educ s9_1q2, scheffe

clear all
*here is where I divide the 2 parts"
use "C:\Users\tomma\OneDrive\Desktop\s1_1.dta"
merge m:m hhcode using "C:\Users\tomma\OneDrive\Desktop\S9_1.dta", nogenerate
merge m:m hhcode using "C:\Users\tomma\OneDrive\Desktop\S5_1_a.dta", nogenerate
merge m:m hhcode using "C:\Users\tomma\OneDrive\Desktop\S5_1_b.dta", nogenerate
merge m:m hhcode using "C:\Users\tomma\OneDrive\Desktop\s8_1.dta", nogenerate
drop if s9_1q1 !=1
drop if educ>14
gen dummy_participation = 1 if s9_1q2 == 2
replace dummy_participation = 0 if s9_1q2==1
regr educ dummy_participation s5_1q2 s5_1q3
regr educ dummy_participation s5_1q14 s5_1q15
regr educ dummy_participation s8_1q3 s8_1q4



Hope someone can help me. Thanks in advance