45 lines
1.1 KiB
Plaintext
45 lines
1.1 KiB
Plaintext
clear all
|
|
set memory 200M
|
|
cd e:\chililabdata\data
|
|
|
|
global refdate = mdy(7,1,$year)
|
|
use individres
|
|
drop if (res_edate != . & res_edate < $refdate)
|
|
drop if (res_sdate != . & res_sdate > $refdate)
|
|
keep individid locationid
|
|
duplicates drop individid, force
|
|
sort individid
|
|
save cross\crossindividres, replace
|
|
use observation
|
|
sort observeid
|
|
save observation, replace
|
|
|
|
use membership
|
|
drop if (mem_edate != . & mem_edate < $refdate)
|
|
drop if (mem_sdate != . & mem_sdate > $refdate)
|
|
duplicates drop individid, force
|
|
rename mem_sobserveid observeid
|
|
sort observeid
|
|
merge observeid using observation
|
|
tab _merge
|
|
drop if _merge !=3
|
|
drop _merge
|
|
rename locationid sociallocid
|
|
gen communeid = substr(sociallocid, 1,2)
|
|
sort individid
|
|
|
|
merge individid using cross\crossindividres
|
|
table _merge
|
|
drop _merge
|
|
gen isresident =0
|
|
replace isresident =(locationid==sociallocid)
|
|
drop if isresident == $isresident
|
|
replace communeid="00" if $communeid ==0
|
|
drop if communeid ! ="0$communeid"
|
|
sort communeid
|
|
collapse (count) midyearpop=mem_episodeid, by (communeid)
|
|
keep communeid midyearpop
|
|
sort communeid
|
|
save cross\MidYearPop, replace
|
|
cd e:\chililabdata
|