! GLIM4 macro implementing the self-controlled case series method ! for evaluating associations between vaccination and adverse events ! ! Version 2.2 5 August 2000 ! ! This macro requires data in the following form: ! var 1: IND_ individual number (in increasing sequential order) ! var 2: AGE_ age at event (order immaterial) ! var 3: STA_ unit before start of obs period for each indiv (>=-1) ! var 4: END_ end of obs period for each indiv (>=0) ! var 5: VC_ vector of length %v containing the vaccine codes ! vars 6 to 6+%a-1: %a sorted age cutpoints (max must be >= END_) ! vars 6+%a to 6+%a+%v-1 : %v sorted vaccine cutpoints (can be tied) ! vars 6+%a+%v to 6+%a+%v+%c-1 : stratifying covariates ! All cutpoints correspond to upper interval limits. ! The %a age cutpoints and the %v vaccine cutpoints, sequentially ! ordered, together with the covariates are entered into three lists which ! constitute the three arguments of the macro, in the order age_list then ! vac_list then cov_list. ! ! A model macro must also be defined; the factors available are: ! I_: individual, eliminated from the fit ! T_: age groups ! V_: vaccine risk groups ! C_1...C_m: fixed covariate factors ! $macro clus! $list L_=%1+%2$ $cal %z1=%a3+1$ $arg set %1 %2 %3$ $switch %z1 noset set$ $cal %a=%len(%1):%v=%len(%2):%l=%a+%v+2$!l: length of HISTory vector $cal %m=%len(K_)$ !m: number of fixed covariates $tab the IND_ l into %t$ !t: total number of individuals $cal %n=%t*%l$ !n: total number of time intervals $tab the VC_ l into %p !p: number of vaccine risk levels $slength %n$ $var %n N_ I_ E_ W_ T_ V_$ $list %m C_$ $cal N_=0:I_=0:E_=0:W_=0:T_=0:V_=0$ $cal %i=1:%j=1:%k=1$ !i: indiv; j: record; k: time interval $cal %z1=1$while %z1 ind$ $cal W_=(E_/=0)$ $use mfac$ $del Z_$ $use modl$ $$endmac ! $macro noset! Defines K_ as null list if no covariates declared $list 0 K_$ $$endmac$ ! $macro set! Defines K_ as third argument if present $list K_=%3$ $$endmac$ ! $macro ind! sets up the vectors for individual i $var %l TMP_ IN_ HIS_ ORD_ TIM_ VAC_ EXP_ NUM_$ $cal IN_=%i$ $cal ORD_=%cu(1)$ $cal HIS_=0:TIM_=0:VAC_=0:EXP_=0:WT_=1:NUM_=0$ $cal HIS_(1)=STA_(%j):HIS_(2)=END_(%j)$ $cal %z1=%a+%v:%z2=0$ $while %z1 hist$ $use sor$ $cal VAC_(%l)=%eq(VAC_(%l),0)+%ne(VAC_(%l),0)*VAC_(%l)$ $cal TIM_(%l)=%a$ $cal %z1=%l-1$ $while %z1 fac$ $cal %z1=1:%z2=1$ $while %z2 tie$ $cal %z1=%l-1$ $while %z1 exp$ $cal TMP_=(ORD_==1)*HIS_:%z1=%cu(TMP_)$ $cal TMP_=(ORD_==2)*HIS_:%z2=%cu(TMP_)$ $cal EXP_=(HIS_>%z1)*(HIS_<=%z2)*EXP_$ $cal %c=%cu((IND_==%i))$ !c: total number of cases for individual i $cal %z1=1:%z2=%j$ $while %z1 case$ $cal %z1=1:%z2=%k:%z3=1$ $cal %z4=1:%z5=(%z4<=%m)$ $while %z1 vars$ $cal %i=%i+1:%j=%j+%c:%k=%k+%l$ $cal %z1=(%i<=%t)$ $del IN_ HIS_ ORD_ TIM_ VAC_ EXP_ NUM_$ $$endmac ! $macro hist! Sets up the HISTory vector and age and vac indicators $cal %z2=%z2+1:%z1=%z1-1:%z3=2+%z2$ $cal HIS_(%z3)=L_[%z2](%j)$ $cal TIM_(%z3)=(%z2<=%a)$ $cal VAC_(%z3)=(%z2>%a)$ $$endmac ! $macro sor! Sorts historical vector and defines TIM and VAC levels $cal TIM_=%cu(TIM_)*TIM_$ $cal VAC_=%cu(VAC_)*VAC_$ $sort TIM_,VAC_,ORD_,HIS_ * HIS_,TIM_,VAC_$ ! ** $$endmac$ ! $macro fac! Fills in the gaps for factors TIM and VAC $cal %z2=TIM_(%z1+1):%z3=VAC_(%z1+1)$ $cal TIM_(%z1)=%ne(TIM_(%z1),0)*TIM_(%z1)+%eq(TIM_(%z1),0)*%z2$ $cal VAC_(%z1)=%ne(VAC_(%z1),0)*VAC_(%z1)+%eq(VAC_(%z1),0)*%z3$ $cal %z1=%z1-1$ $endmac$ ! $macro tie! Alters the factor levels for tied cutpoints $cal %z3=TIM_(%z1):%z4=VAC_(%z1):%z5=HIS_(%z1):%z6=HIS_(%z1+1)$ $cal TIM_(%z1+1)=%if((%z5==%z6),%z3,TIM_(%z1+1))$ $cal VAC_(%z1+1)=%if((%z5==%z6),%z4,VAC_(%z1+1))$ $cal %z1=%z1+1:%z2=(%z1<%l)$ $$endmac$ ! $macro exp! Calculates exposure time variable $cal EXP_(%z1+1)=HIS_(%z1+1)-HIS_(%z1)$ $cal %z1=%z1-1$ $$endmac ! $macro case! Calculates the number of cases in each interval $cal %z3=AGE_(%z2):%z4=%l-1$ $while %z4 int$ $cal %z2=%z2+1$ $cal %z1=(%z2<=%j+%c-1)$ $$endmac$ ! $macro int! Identifies which interval each case belongs to $cal NUM_(%z4+1)=NUM_(%z4+1)+(HIS_(%z4)<%z3)*(%z3<=HIS_(%z4+1))$ $cal %z4=%z4-1$ $$endmac$ ! $macro vars! Constructs the next l entries of the model variables $cal N_(%z2)=NUM_(%z3)$ $cal I_(%z2)=IN_(%z3)$ $cal E_(%z2)=EXP_(%z3)$ $cal T_(%z2)=TIM_(%z3)$ $cal V_(%z2)=VAC_(%z3)$ $while %z5 cov$ $cal %z2=%z2+1:%z3=%z3+1$ $cal %z4=1:%z5=(%z4<=%m)$ $cal %z1=(%z3<=%l)$ $$endmac$ ! $macro cov! Constructs the covariate vectors $cal C_[%z4](%z2)=K_[%z4](%j)$ $cal %z4=%z4+1:%z5=(%z4<=%m)$ $$endmac$ ! $macro mfac! Recodes the vaccine variable and declares the model factors $cal V_=VC_(V_)$ $fac I_ %t T_ %a V_ %p$ $num Z_$ $cal Z_=1:%z2=(Z_<=%m)$ $while %z2 cfac$ $$endmac$ ! $macro cfac! Sets the factor levels of the fixed covariates $tab the K_[Z_] l into %z3$ $fac C_[Z_] %z3$ $pick C_[Z_] W_$ $cal Z_=Z_+1:%z2=(Z_<=%m)$ $$endmac$ ! $macro modl! Fits the model $cal E_=E_+(W_==0):O_=%log(E_)$ $pick N_,O_,I_,T_,V_ W_$ $yvar N_$error p$offset O_$eliminate I_$ $pr 'Details of observation periods:'$ $pr 'Start:'$ $tab the STA_ s:the STA_ l$ $pr 'End:'$ $tab the END_ s:the END_ l$ $pr ;$ $pr 'Distribution of events by interval since vaccination:'$ $tab the N_ t for V_$ $pr ;$ $pr 'Distribution of events by age group:'$ $tab the N_ t for T_$ $pr ;$ $fit #model$d u$ $$endmac$ ! $return