Files
Dss/Chililabdata/code/GenLongMembership.do
admin 8c43da1d1c Uloading
Uloading
2025-08-02 05:26:16 +07:00

26 lines
796 B
Plaintext

clear
cd e:\chililabdata\data
use membership
sort individid
drop if individid==""
replace mem_sdate=mem_sdate/86400000
rename mem_sdate sdate
format sdate %td
gen year = year( sdate)
gen h = halfyear(sdate)
gen round = yh(year,h)-89
sort individid round
duplicates drop individid round, force
gen period = round[_n+1]-round
replace period = 109-89 -round if individ != individid[_n+1]
drop mem_episodeid mem_sobserveid mem_seventtype mem_eobserveid mem_edate mem_eeventtype mem_no socialgpidGuid mem_sobserveidGuid mem_eobserveidGuid h year
expand period
sort individid round
by individid round: gen p=_n-1
replace round = round+p
tostring round, generate(rounds)
replace rounds = "0" + rounds if strlen(rounds) == 1
gen socialkeys = socialgpid + rounds
drop period p
save rMembership, replace