Monday, April 24, 2006

Do Pregnant Women Quit Smoking ? Do women start quiting before they are pregnant ?

2 comments:

Robert said...

drop _all
set mem 100m

use a_w8rel,clear
keep if rel == 2
sort country pid2
save ja_w8rel,replace

clear
use a_w7rel,clear
keep if rel == 2
sort country pid2
save ja_w7rel,replace


merge country pid2 using ja_w8rel
keep if _m==2
drop _m
/* these should be new kids */
gen double pid = pid1
sort country pid
save newkids,replace


clear
use a_w8r
sort country pid
save,replace


clear
use a_w8p
sort country pid
save,replace

clear
use a_w7p
rename pd004 sex
keep if sex == 2 /* gender == female */
sort country pid
merge country pid using newkids
keep if _m==3 /* mother with newly arrived kids */
drop _m
save newkids,replace

replace pid = pid2
sort country pid
merge country pid using a_w8r
keep if _m==3
drop _m

keep if rd001==.
keep if pd003 < 41 /* keep mothers younger than 41 */

keep if pg006 > 0
keep if rd002 >0
gen long diff = pg006 - rd002
replace diff = diff-12 if diff >=0


keep country pid1 pid2 hid pg006 pg007 rd002 wave pd003 diff sex
gen double pid=pid1
drop if pg006 <0
gen pg006_old=pg006
drop pg006
sort country pid
merge country pid using a_w8p

keep if _m==3
drop _m
drop if pg006 <0
gen diffint = pg006 - pg006_old
replace pg006 = pg006_old
drop pg006_old
keep country pid pid1 pid2 hid pg006 pg007 rd002 wave pd003 diffint diff sex
gen temp = diff + diffint
keep if temp <=0
drop temp
drop if diff == -12 & diffint == 0

gen ybirth = 2000 + ((pg006 - diff) > 12)
replace pid = pid2
recast double pid1 pid2 pid
keep country hid pid1 pid2 ybirth sex

sort country pid2
save newmkids,replace

Robert said...

the program below called nnkidscheck7.do should do for the 7th wave what newnewkids does for the 8th (that is guess kids birth year). I don't have the data to check that the guessed year corresponds to the available rd001

rop _all
set mem 100m

use a_w6rel,clear
keep if rel == 2
sort country pid2
save ja_w6rel,replace

clear
use a_w7rel,clear
keep if rel == 2
sort country pid2
save ja_w7rel,replace


merge country pid2 using ja_w6rel
keep if _m==2
drop _m
/* these should be new kids */
gen double pid = pid1
sort country pid
save newkids,replace


clear
use a_w7r
sort country pid
save,replace


clear
use a_w7p
sort country pid
save,replace

clear
use a_w6p
rename pd004 sex
keep if sex == 2 /* gender == female */
sort country pid
merge country pid using newkids
keep if _m==3 /* mother with newly arrived kids */
drop _m
save newkids,replace

replace pid = pid2
sort country pid
merge country pid using a_w6r
keep if _m==3
drop _m

/* to check we want to guess birth year even if we know it so this line commented out
keep if rd001==. */

keep if pd003 < 41 /* keep mothers younger than 41 */

keep if pg006 > 0
keep if rd002 >0
gen long difg = pg006 - rd002
replace difg = difg-12 if difg >=0

drop pid
gen double pid=pid2

drop if pg006 <0
gen pg006_old=pg006
drop pg006
sort country pid
merge country pid using a_w8p

keep if _m==3
drop _m
drop if pg006 <0
gen diffint = pg006 - pg006_old
replace pg006 = pg006_old
drop pg006_old

gen temp = difg + diffint
keep if temp <=0
drop temp
drop if difg == -12 & diffint == 0

gen rd001g = 1999 + ((pg006 - difg) > 12)
recast double pid1 pid2 pid
gen desc_id = pid2
gen ybirth = 1999 + ((pg006 - diff) > 12)

sort country hid pid
save c:\programmi\stata9\preg\nnmkids7,replace

drop _all

use c:\programmi\stata9\preg\a_w7r

sort country hid pid


merge country hid pid using c:\programmi\stata9\preg\nnmkids7

gen oops = rd001-rd001g
sum oops
sum oops if pid==desc_id