This document is a supplementary material for the following paper:
McGrath et al. (2020) Comorbidity within mental disorders: a comprehensive analysis based on 145,990 survey respondents from 27 countries. Epidemiology and Psychiatric Sciences
Authors: John McGrath, Carmen Lim, Oleguer Plana-Ripoll, Yan Holtz, Esben Agerbo, Natalie Momen,…,Ron Kessler, Peter de Jonge
Preamble:
The WHO World Mental Health Surveys Initiative have coordinated a series of general population surveys to estimate the prevalence of mental disorders, to evaluate risk factors for targeted interventions, and to study patterns of barriers to service use. This paper estimates the associations between 24 DSM-IV mental disorders based on retrospectively reported age-of-onset from 27 surveys. We have examined all 576 logically possible temporally-ordered pairwise associations using Cox Proportional Hazards model. For replication purposes, we have provided SAS codes to estimate:
Overall hazard ratios
Time lagged hazard ratios
cumulative incidence curves (absolute risk)
Link to the interactive website with all the results are available here.
Data preparation
For this paper, we had to load 3 datasets for every WMH survey prior to analysing data. These are (i) main dataset (raw variables), (ii) diagnostic variable dataset, and (iii) demographics variable dataset. Each dataset contains a unique sampleid for each respondent. sampleid will be used to merge dataset.
We had to load 3 datasets for every WMH survey prior to analysing data. These are (i) main dataset (raw variables), (ii) diagnostic variable dataset, and (iii) demographics variable dataset. Each dataset contains a unique sampleid for each respondent. sampleid will be used to merge dataset.
%MACRO make_data (path = , data = );
DATA out0.&data;
MERGE out0.&data._main (IN = In&data._main)
out0.&data._dem (IN = In&data._dem)
out0.&data._dia (IN = In&data._dia);
BY sampleid;
IF In&data._main = 1 AND In&data._dem = 1 AND In&data._dia = 1;
RUN;
%MEND make_data;
%make_data (path = safrica, data = safrica)
%make_data (path = ukraine, data = ukraine)
%make_data (path = argt, data = argentina)
%make_data (path = medellin, data = medellin)
%make_data (path = murcia, data = murcia)
%make_data (path = aust, data = australia)
%make_data (path = peru, data = peru)
%make_data (path = poland, data = poland)
%make_data (path = portugal, data = portugal)
%make_data (path = nireland, data = nireland)
%make_data (path = shenzhen, data = shenzhen)
%make_data (path = brazil, data = brazil)
%make_data (path = iraq, data = iraq)
%make_data (path = romania, data = romania)
%make_data (path = bulgaria, data = bulgaria)
%make_data (path = nzl, data = nzl)
%make_data (path = israel, data = israel)
%make_data (path = nigeria, data = nigeria)
%make_data (path = lebanon, data = lebanon)
%make_data (path = japan, data = japan)
%make_data (path = mexico, data = mexico)
%make_data (path = colombia, data = colombia)
%make_data (path = ncsr, data = ncsr)
%make_data (path = esemed, data = esemed)
;
Concatenate all surveys
DATA out0.all1;
SET out0.colombia out0.belgium out0.france out0.germany out0.italy
out0.netherlands out0.spain out0.mexico out0.ncsr out0.japanall
out0.lebanon out0.nigeriaall out0.ukraine out0.israel out0.nzl
out0.safrica out0.bulgaria out0.romania out0.iraq out0.brazil
out0.shenzhen out0.nireland out0.portugal out0.poland out0.peru
out0.australia out0.murcia out0.medellin out0.argentina ;
RUN;
Mental disorders
The 24 mental disorders included in this publication were dsm_mde (major depression), dsm_bi3 (bipolar disorder), dsm_dys (dysthymia), dsm_pds (panic disorder), dsm_gad (generalized anxiety disorder), dsm_so (social phobia), dsm_sp (specific phobia), dsm_ago (agoraphobia), dsm_pts (PTSD), dsm_ocd (OCD), dsm_sad (child separation anxiety disorder), dsm_asa (adult separation anxiety disorder), dsm_ied (IED), dsm_cd (conduct disorder), dsm_add (ADHD), dsm_odd (oppositional defiant disorder), dsm_ano (anorexia nervosa), dsm_bul (bulimia nervosa), dsm_bingeany (binge eating disorder), dsm_ala (alcohol abuse), dsm_ald (alcohol dependence), dsm_dra (drug abuse), and dsm_drd (drug dependence).
However, not all the surveys assess all the disorders listed above. When deriving the estimates for each pair of disorders, surveys that did not assess the disorders of interest were excluded from the analyses. For more information, please see list of disorders.xlsx.
Dataset structure
Below is an illustration of the dataset structure. For simplicity purposes, we will only consider 6 mental disorders with major depression, separation anxiety, social phobia, specific phobia, panic disorder, alcohol abuse and the age of onset for each disorder (mde_ond, sad_ond, so_ond, sp_ond, pd_ond, ala_ond). For example, respondent 1001 developed major depression at age 15 and alcohol abuse at age 20 prior to his interview at age 22.
sampleid | age | sex | dsm_mde | mde_ond | dsm_sad | sad_ond | dsm_so | so_ond | dsm_sp | sp_ond | dsm_pds | pds_ond | dsm_ala | ala_ond |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1001 | 22 | F | Yes | 15 | No | No | No | No | Yes | 20 | ||||
1002 | 70 | M | Yes | 35 | No | No | Yes | 9 | Yes | 33 | Yes | 22 | ||
1003 | 66 | M | No | No | No | No | No | No | ||||||
1004 | 18 | F | No | Yes | 10 | Yes | 8 | No | No | No |
Break ties
The WMH surveys assessed age of onset of disorders in whole years, and respondents may report occurrences of two or more disorders in any given year (i.e. presence of ties). Exclusion of these ties would underestimate all the associations. In keeping with our previous analyses, we broke ties by randomly reassigning a proportion of those with the same year onset to having the prior disorder a year earlier. For illustrative purposes, we will use major depression as prior disorder and alcohol abuse as later disorder to demonstrate how we reallocate ties.
%MACRO mde (var = ala, n = 1 );
DATA temp;
SET out0.all1;
/*Identify respondents with both disorder of interest*/
IF dsm_mde = 1 AND dsm_&var. = 1 THEN DO;
/*Step 1: Create variable for depression onset prior to alcohol abuse onset*/
IF mde_ond < &var._ond THEN mde_&var. = 1; ELSE mde_&var. = 0;
/*Step 2: Create variable for depression onset in same year as alcohol abuse onset*/
IF mde_ond = &var._ond THEN mde_&var._same = 1; ELSE mde_&var._same = 0;
/*Step 3: Create variable for depression onset after alcohol abuse onset*/
IF mde_ond > &var._ond THEN &var._mde = 1; ELSE &var._mde = 0;
END;
RUN;
%MACRO subset(where = , var = , i = , j = );
PROC FREQ DATA = temp; &where TABLE &var /LIST MISSING OUT = data&i.; RUN;
DATA data&i. (KEEP = j COUNT&i.);
SET data&i.;
%IF &i = 1 OR &i = 3%THEN %DO;
IF _N_ = 1;
%END;
%IF &i ~= 1 %THEN %DO;
IF _N_ = 2;
%END;
j = &j.;
RENAME count = count&i.;
RUN;
%MEND subset;
/*Step 4: Compute crosstabs to calculate respondents in each category*/
%subset(var = sample_sel&n.,i = 1, j = 1)
%subset(where = WHERE sample_sel&n. = 1 AND dsm_mde = 1 AND dsm_&var. = 1;,var = mde_&var.,i = 2, j = 1)
%subset(where = WHERE sample_sel&n. = 1 AND dsm_mde = 1 AND dsm_&var. = 1;,var = mde_&var.,i = 3, j = 1)
%subset(where = WHERE sample_sel&n. = 1 AND dsm_mde = 1 AND dsm_&var. = 1;,var = mde_&var._same,i = 4, j = 1)
%subset(where = WHERE sample_sel&n. = 1 AND dsm_mde = 1 AND dsm_&var. = 1;,var = &var._mde,i = 5, j = 1)
;
/*Step 5: Combine the above results into a single line*/
DATA &var; MERGE %DO i = 1 %TO 5; data&i. %END; ;BY j; RUN;
/*Step 6: Turn the numbers from crosstabs into a macro variable*/
DATA &var (DROP = count1 count3);
SET &var;
total = count1 + count2;
RENAME count2 = sample_sel count4 = atob count5 = sameonset count6 = btoa;
RUN;
DATA &var ;
SET &var;
bothdx = atob+sameonset+btoa;
RUN;
PROC PRINT DATA = &var.;ID atob sameonset btoa bothdx sample_sel; RUN;
DATA _NULL_;
SET &var.;
CALL SYMPUT("sample_sel",sample_sel);
CALL SYMPUT("atob",atob);
CALL SYMPUT("sameonset",sameonset);
CALL SYMPUT("btoa",btoa);
prop = atob/(atob+btoa);
n_extract = INT(prop*sameonset);
CALL SYMPUT("prop",prop);
CALL SYMPUT("n_extract",n_extract);
RUN;
%PUT the proportion of dsm_mde to dsm_&var. is ∝
%PUT number needs to be sampled from the full sample is &n_extract;
/*Step 7: Use the SURVEYSELECT procedure to sample respondents with same year onset*/
PROC SURVEYSELECT DATA = temp METHOD = SYS SEED = 88888 N = &n_extract OUT = temp1;
WHERE mde_&var._same = 1;
CONTROL country age sex ;
RUN;
/*Step 8: Error checking mechanism*/
/* Delete respondents with same year onset in the TEMP dataset*/
DATA temp; SET temp; IF mde_&var._same = 1 THEN DELETE; new_mde_ond = mde_ond;flag = 0; RUN;
/* TEMP1 from SURVEYSELECT will contain respondents whom we need to reassign to having the
prior disorder the year before*/
DATA temp1; SET temp1; new_mde_ond = mde_ond - 1;flag = 1; RUN;
/*Concatenate both TEMP and TEMP1*/
DATA new;SET temp temp1 ; RUN;
%MEND;
Split the time interval for each respondent
We have performed our analysis using the counting process method. We started by constructing a dataset that contains multiple records for every respondents, with each record corresponds to an interval of time during which the variable of interest remain constant. For respondents without comorbid disorders, only one interval is needed. For respondents with comorbid disorders, multiple time intervals maybe required depending on each respondent’s number of comorbid disorders (including the prior disorder).
Here is a brief explanation of the codes below on how to construct the dataset with multiple records using major depression as the prior disorder:
Briefly, the ‘IF-DO’ statement begins a block of definitions for those without the later disorder. The stop time for these respondents is set to be the same as the age at interview because these respondents do not have the later disorder. They are considered to be censored at their age of interview. Step 2 and 3 create some indicator variables that tell us when a respondent’s disorder status changes. The ‘ELSE-DO’ statement begins a block of variable definitions for those with the later disorder. The stop time for these respondents is set to be the age of onset of the later disorder. Step 7 and 8 create some indicator variables that tell us when a respondent’s disorder status changes.
The DO statements in each block loops over the list of mental disorders studied in this paper, where a time interval will be created for every additional disorder that a respondent had up until their the onset of the later disorder or age at interview (whichever occurs first). The OUTPUT statement writes the record to the new dataset. By default, all variables in the original dataset are included in this record.
For handling time-varying variables, we have utilised the counting process method which means there maybe multiple records for every respondents, with each record corresponding to an interval of time during with the variable of interest remain constant. Here is a brief explanation of how it works, the ‘IF-DO’ statement begins a block of definitions for those without later disorder. The stop time for these respondents is set to be the same as the age at interview. The OUTPUT statement writes the record to the new dataset. By default, all variables in the original dataset are included in this record. The ‘ELSE-DO’ statement begins a block of variable definitions for those with later disorder. Note: our prior disorder is still major depression
%MACRO count_proc (var = , n = 1 );
/* Step 1: Data are expanded from one record per respondent to one record per interval between each disorder
onset, per respondent*/
DATA new2;
SET new;
/*Define a string of disorder onsets*/
%LET string = pd_ond, sp_ond, so_ond, ano_ond, bul_ond, bingeany_ond, ocd_ond,
asa_ond, sad_ond, add_ond, odd_ond, pts_ond, ied_ond, cd_ond,
ago_ond, dys_ond, ala_ond, ald_ond2, dra_ond2, drd_ond2, tbd_ond,
gad_ond, bi3_ond;
/*var1-var24 = dx acronyms, ovar1-ovar24 = disorder onset*/
%LET var1 = mde; %LET ovar1 = new_mde_ond;
%LET var2 = pd; %LET ovar2 = pd_ond;
%LET var3 = sp; %LET ovar3 = sp_ond;
%LET var4 = so; %LET ovar4 = so_ond;
%LET var5 = ano; %LET ovar5 = ano_ond;
%LET var6 = bul; %LET ovar6 = bul_ond;
%LET var7 = bingeany; %LET ovar7 = bingeany_ond;
%LET var8 = ocd; %LET ovar8 = ocd_ond;
%LET var9 = asa; %LET ovar9 = asa_ond;
%LET var10 = sad; %LET ovar10 = sad_ond;
%LET var11 = add; %LET ovar11 = add_ond;
%LET var12 = odd; %LET ovar12 = odd_ond;
%LET var13 = pts; %LET ovar13 = pts_ond;
%LET var14 = ied; %LET ovar14 = ied_ond;
%LET var15 = cd; %LET ovar15 = cd_ond;
%LET var16 = ago; %LET ovar16 = ago_ond;
%LET var17 = dys; %LET ovar17 = dys_ond;
%LET var18 = ala; %LET ovar18 = ala_ond;
%LET var19 = ald; %LET ovar19 = ald_ond2;
%LET var20 = dra; %LET ovar20 = dra_ond2;
%LET var21 = drd; %LET ovar21 = drd_ond2;
%LET var22 = tbd; %LET ovar22 = tbd_ond;
%LET var23 = gad; %LET ovar23 = gad_ond;
%LET var24 = bi3; %LET ovar24 = bi3_ond;
/* Step 2: Create time-varying variables for major depression*/
expo_&var1 = 0;
/* Step 3: Create time-varying variables for other mental disorders*/
expo_&var2._&var1 = 0; expo_&var3._&var1 = 0; expo_&var4._&var1 = 0;
/* Step 2: Create time-varying variables for major depression*/
expo_&var1 = 0;
/* Step 3: Create time-varying variables for other mental disorders.
If other disorder precedes major depression, then these variables will be coded 1*/
expo_&var2._&var1 = 0; expo_&var3._&var1 = 0; expo_&var4._&var1 = 0;
expo_&var5._&var1 = 0; expo_&var6._&var1 = 0; expo_&var7._&var1 = 0;
expo_&var8._&var1 = 0; expo_&var9._&var1 = 0; expo_&var10._&var1 = 0;
expo_&var11._&var1 = 0; expo_&var12._&var1 = 0; expo_&var13._&var1 = 0;
expo_&var14._&var1 = 0; expo_&var15._&var1 = 0; expo_&var16._&var1 = 0;
expo_&var17._&var1 = 0; expo_&var18._&var1 = 0; expo_&var19._&var1 = 0;
expo_&var20._&var1 = 0; expo_&var21._&var1 = 0; expo_&var22._&var1 = 0;
expo_&var23._&var1 = 0; expo_&var24._&var1 = 0;
/* Step 4: Set start time = 1*/
start = 1;
/* Step 5: Later disorder is not present*/
/* Step 5: If later disorder is not present, then the start of the interval is 1, stop of the interval is age at interview*/
IF dsm_&var = 0 THEN DO;
stop = age;
i = 0;
OUTPUT;
/* Step 5: If later disorder is not present, then the start of the interval is 1, stop of the interval is age at interview*/
%DO b = 2 %TO 24;
IF stop < age THEN DO;
/*assign a new start time if a change in status has occurred*/
start = stop;
stop = SMALLEST(&b.,&string. );
i = 0;
/*If other disorder precedes major depression, then these variables will be coded 1*/
IF start = &ovar2 AND . < &ovar2 THEN expo_&var2._&var1 = 1;
IF start = &ovar3 AND . < &ovar3 THEN expo_&var3._&var1 = 1;
IF start = &ovar4 AND . < &ovar4 THEN expo_&var4._&var1 = 1;
IF start = &ovar5 AND . < &ovar5 THEN expo_&var5._&var1 = 1;
IF start = &ovar6 AND . < &ovar6 THEN expo_&var6._&var1 = 1;
IF start = &ovar7 AND . < &ovar7 THEN expo_&var7._&var1 = 1;
IF start = &ovar8 AND . < &ovar8 THEN expo_&var8._&var1 = 1;
IF start = &ovar9 AND . < &ovar9 THEN expo_&var9._&var1 = 1;
IF start = &ovar10 AND . < &ovar10 THEN expo_&var10._&var1 = 1;
IF start = &ovar11 AND . < &ovar11 THEN expo_&var11._&var1 = 1;
IF start = &ovar12 AND . < &ovar12 THEN expo_&var12._&var1 = 1;
IF start = &ovar13 AND . < &ovar13 THEN expo_&var13._&var1 = 1;
IF start = &ovar14 AND . < &ovar14 THEN expo_&var14._&var1 = 1;
IF start = &ovar15 AND . < &ovar15 THEN expo_&var15._&var1 = 1;
IF start = &ovar16 AND . < &ovar16 THEN expo_&var16._&var1 = 1;
IF start = &ovar17 AND . < &ovar17 THEN expo_&var17._&var1 = 1;
IF start = &ovar18 AND . < &ovar18 THEN expo_&var18._&var1 = 1;
IF start = &ovar19 AND . < &ovar19 THEN expo_&var19._&var1 = 1;
IF start = &ovar20 AND . < &ovar20 THEN expo_&var20._&var1 = 1;
IF start = &ovar21 AND . < &ovar21 THEN expo_&var21._&var1 = 1;
IF start = &ovar22 AND . < &ovar22 THEN expo_&var22._&var1 = 1;
IF start = &ovar23 AND . < &ovar23 THEN expo_&var23._&var1 = 1;
IF start = &ovar24 AND . < &ovar24 THEN expo_&var24._&var1 = 1;
IF start = . THEN DELETE;
OUTPUT;
END;
%END;
DROP b;
END;
/* Step 6: Later disorder is present*/
ELSE DO;
stop = SMALLEST(1,&string. ,new_&var1._ond) ;
i = 0;
/* Step 7: Create time-varying variables for major depression*/
expo_&var1 = 0;
/* Step 8: Create time-varying variables for other mental disorders*/
/*If other disorder precedes major depression, then these variables will be coded 1*/
expo_&var2._&var1 = 0; expo_&var3._&var1 = 0; expo_&var4._&var1 = 0;
expo_&var5._&var1 = 0; expo_&var6._&var1 = 0; expo_&var7._&var1 = 0;
expo_&var8._&var1 = 0; expo_&var9._&var1 = 0; expo_&var10._&var1 = 0;
expo_&var11._&var1 = 0; expo_&var12._&var1 = 0; expo_&var13._&var1 = 0;
expo_&var14._&var1 = 0; expo_&var15._&var1 = 0; expo_&var16._&var1 = 0;
expo_&var17._&var1 = 0; expo_&var18._&var1 = 0; expo_&var19._&var1 = 0;
expo_&var20._&var1 = 0; expo_&var21._&var1 = 0; expo_&var22._&var1 = 0;
expo_&var23._&var1 = 0; expo_&var24._&var1 = 0;
OUTPUT;
%DO a = 2 %TO 25;
IF stop < age THEN DO;
/*assign a new start time if a change in status has occurred*/
start = stop;
stop = SMALLEST(&a.,&string. ,&ovar1);
/*Error checking mechanism*/
IF start = &ovar1 THEN DO; stop= &ovar1+1; END;
IF stop > age OR stop = . THEN stop = age;
i = 0;
/*If other disorder precedes major depression, then these variables will be coded 1*/
IF start = &ovar1 THEN expo_&var1 = 1;
IF expo_&var1 = 1 THEN i = 1;
IF start = &ovar2 AND . < &ovar2 < &ovar1 THEN expo_&var2._&var1 = 1;
IF start = &ovar3 AND . < &ovar3 < &ovar1 THEN expo_&var3._&var1 = 1;
IF start = &ovar4 AND . < &ovar4 < &ovar1 THEN expo_&var4._&var1 = 1;
IF start = &ovar5 AND . < &ovar5 < &ovar1 THEN expo_&var5._&var1 = 1;
IF start = &ovar6 AND . < &ovar6 < &ovar1 THEN expo_&var6._&var1 = 1;
IF start = &ovar7 AND . < &ovar7 < &ovar1 THEN expo_&var7._&var1 = 1;
IF start = &ovar8 AND . < &ovar8 < &ovar1 THEN expo_&var8._&var1 = 1;
IF start = &ovar9 AND . < &ovar9 < &ovar1 THEN expo_&var9._&var1 = 1;
IF start = &ovar10 AND . < &ovar10 < &ovar1 THEN expo_&var10._&var1 = 1;
IF start = &ovar11 AND . < &ovar11 < &ovar1 THEN expo_&var11._&var1 = 1;
IF start = &ovar12 AND . < &ovar12 < &ovar1 THEN expo_&var12._&var1 = 1;
IF start = &ovar13 AND . < &ovar13 < &ovar1 THEN expo_&var13._&var1 = 1;
IF start = &ovar14 AND . < &ovar14 < &ovar1 THEN expo_&var14._&var1 = 1;
IF start = &ovar15 AND . < &ovar15 < &ovar1 THEN expo_&var15._&var1 = 1;
IF start = &ovar16 AND . < &ovar16 < &ovar1 THEN expo_&var16._&var1 = 1;
IF start = &ovar17 AND . < &ovar17 < &ovar1 THEN expo_&var17._&var1 = 1;
IF start = &ovar18 AND . < &ovar18 < &ovar1 THEN expo_&var18._&var1 = 1;
IF start = &ovar19 AND . < &ovar19 < &ovar1 THEN expo_&var19._&var1 = 1;
IF start = &ovar20 AND . < &ovar20 < &ovar1 THEN expo_&var20._&var1 = 1;
IF start = &ovar21 AND . < &ovar21 < &ovar1 THEN expo_&var21._&var1 = 1;
IF start = &ovar22 AND . < &ovar22 < &ovar1 THEN expo_&var22._&var1 = 1;
IF start = &ovar23 AND . < &ovar23 < &ovar1 THEN expo_&var23._&var1 = 1;
IF start = &ovar24 AND . < &ovar24 < &ovar1 THEN expo_&var24._&var1 = 1;
OUTPUT;
END;
%END;
DROP a;
END;
RUN;
/*Error checking mechanism*/
DATA new2a;
SET new2;
IF dsm_&var1 = 1 THEN DO;
IF start >= &ovar1 THEN DELETE;
END;
IF stop = . THEN stop = age;
RUN;
DATA new3;
SET new2;
IF i = 1 AND start = &ovar1 AND stop = &ovar1 + 1;
RUN;
/* Step 9: This step is to change the stop interval to 1,2,5,10,15 years since the onset of prior disorder*/
/*This step is to change the stop interval to 1,2,5,10,15 years since the onset of prior disorder*/
DATA new3a;
SET new3;
t2 = &ovar1 + 3; t5 = &ovar1 + 8; t10 = &ovar1 + 18; t15 = &ovar1 + 33; t15a = &ovar1 + 70;
IF start = &ovar1 THEN DO;
start = &ovar1;
stop = &ovar1 + 1 ;
i = 1;
OUTPUT;
start = stop;
stop = SMALLEST(1,t2,t5,t10,t15,t15a);
IF stop > age OR stop = . THEN stop = age;
i = 2;
IF start = stop THEN DELETE;
OUTPUT;
start = stop;
stop = SMALLEST(2,t2,t5,t10,t15,t15a);
IF stop > age OR stop = . THEN stop = age;
i = 3;
IF start = stop THEN DELETE;
OUTPUT;
start = stop;
stop = SMALLEST(3,t2,t5,t10,t15,t15a);
IF stop > age OR stop = . THEN stop = age;
i = 4;
IF start = stop THEN DELETE;
OUTPUT;
start = stop;
stop = SMALLEST(4,t2,t5,t10,t15,t15a);
IF stop > age OR stop = . THEN stop = age;
i = 5;
IF start = stop THEN DELETE;
OUTPUT;
start = stop;
stop = SMALLEST(5,t2,t5,t10,t15,t15a);
IF stop > age OR stop = . THEN stop = age;
i = 6;
IF start = stop THEN DELETE;
OUTPUT;
END;
IF stop < age THEN DO;
start = stop;
stop = age;
OUTPUT;
END;
RUN;
PROC SORT DATA = new2a; BY sampleid; RUN;
PROC SORT DATA = new3a; BY sampleid; RUN;
DATA new4;
SET new2a new3a;
BY sampleid;
RUN;
DATA new4; SET new4; IF start = stop THEN DELETE;RUN;
%MEND;
Dataset structure
Like previous example, we will only consider 6 mental disorders with major depression, social phobia, specific phobia, separation anxiety disorder, panic disorder, alcohol abuse. Major depression is considered to be the prior disorder.
Respondent 1001 developed major depression at age 15 with separation anxiety at age 7, social phobia at age 14 prior to his interview at age 22.
respondent | age | start | stop | time | time.mde | time.so | time.pds | time.sad | time.sp | time.ala |
---|---|---|---|---|---|---|---|---|---|---|
1001 | 22 | 1 | 7 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
7 | 14 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | ||
14 | 15 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | ||
15 | 16 | 0-1 year | 1 | 1 | 0 | 1 | 0 | 0 | ||
16 | 18 | 1-2 years | 1 | 1 | 0 | 1 | 0 | 0 | ||
18 | 22 | 2-5 years | 1 | 1 | 0 | 1 | 0 | 0 |
Respondent 1002 developed major depression at age 35 with specific phobia at age 9, alcohol abuse at age 22, panic disorder at age 33 prior to his interview at age 70.
respondent | age | start | stop | time | time.mde | time.so | time.pds | time.sad | time.sp | time.ala |
---|---|---|---|---|---|---|---|---|---|---|
1002 | 70 | 1 | 9 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
9 | 22 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | ||
22 | 33 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | ||
33 | 35 | 0 | 0 | 0 | 1 | 0 | 1 | 1 | ||
35 | 36 | 0-1 year | 1 | 0 | 1 | 0 | 1 | 1 | ||
36 | 38 | 1-2 years | 1 | 0 | 1 | 0 | 1 | 1 | ||
38 | 43 | 2-5 years | 1 | 0 | 1 | 0 | 1 | 1 | ||
43 | 53 | 5-10 years | 1 | 0 | 1 | 0 | 1 | 1 | ||
53 | 68 | 10-15 years | 1 | 0 | 1 | 0 | 1 | 1 | ||
68 | 70 | > 15 years | 1 | 0 | 1 | 0 | 1 | 1 |
Respondent 1003 did not developed major depression and do not have other comorbid disorders.
respondent | age | start | stop | time | time.mde | time.so | time.pds | time.sad | time.sp | time.ala |
---|---|---|---|---|---|---|---|---|---|---|
1003 | 66 | 1 | 66 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Respondent 1004 did not developed major depression but has other comorbid disorders: social phobia at age 8, separation anxiety at age 10 prior to his interview at age 18.
respondent | age | start | stop | time | time.mde | time.so | time.pds | time.sad | time.sp | time.ala |
---|---|---|---|---|---|---|---|---|---|---|
1004 | 18 | 1 | 8 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
8 | 10 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | ||
10 | 12 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | ||
12 | 18 | 0 | 0 | 1 | 0 | 1 | 0 | 0 |
Overall hazard ratios
To estimate the model, we use the counting process syntax, specifying both the starting time and the stopping time for each record.
%MACRO a(var = , n = , weight = , country =);
PROC SURVEYPHREG DATA = new4;
WHERE &weight >0 AND sample_sel&n. = 1;
CLUSTER secu;
STRATA str15;
WEIGHT &weight;
MODEL (start,stop)*dsm_&var.(0) = &country
age18_29 age30_44 age45_59
sexf
expo_&priordx/ RISKLIMIT TIES = EFRON;
RUN;
%MEND;
%a(var = ala, n = 7, weight = alwt,
country = colombia australia iraq nigeriaall mexico
romania brazil bulgaria lebanon peru
safrica belgium france germany italy
netherlands spain japanall nzl nireland
portugal israel poland murcia argentina
medellin ukraine);
Lagged hazard ratios
%MACRO lag_models (priordx = , weight = , var = , country = , n = );
DATA new4;
SET new4;
zerotooneyr_&priordx = 0; onetotwoyrs_&priordx = 0; twotofiveyrs_&priordx = 0; fivetotenyrs_&priordx =0;
tentofifteenyrs_&priordx =0; fifteenormoreyrs_&priordx = 0;
IF i = 1 THEN zerotooneyr_&priordx = 1;
IF i = 2 THEN onetotwoyrs_&priordx = 1;
IF i = 3 THEN twotofiveyrs_&priordx = 1;
IF i = 4 THEN fivetotenyrs_&priordx = 1;
IF i = 5 THEN tentofifteenyrs_&priordx = 1;
IF i = 6 THEN fifteenormoreyrs_&priordx = 1;
RUN;
PROC SURVEYPHREG DATA = new4;
WHERE &weight >0 AND sample_sel&n. = 1;
CLUSTER secu;
STRATA str15;
WEIGHT &weight;
MODEL (start,stop)*dsm_&var.(0) = &country
age18_29 age30_44 age45_59
sexf
zerotooneyr_&priordx
onetotwoyrs_&priordx
twotofiveyrs_&priordx
fivetotenyrs_&priordx
tentofifteenyrs_&priordx
fifteenormoreyrs_&priordx / RISKLIMIT TIES = EFRON;
RUN;
%MEND;
Cumulative incidence curves
%MACRO cum_inc (type = , priordx = , n = , weight = );
ODS OUTPUT ProductLimitEstimates = aoo;
PROC LIFETEST DATA = new NELSON ;
%IF &type = all %THEN %DO;
WHERE dsm_&priordx = 1 AND sample_sel&n. = 1 ;
%END;
%IF &type = female %THEN %DO;
WHERE dsm_&priordx = 1 AND sample_sel&n. = 1 AND sexf = 1 ;
%END;
%IF &type = male %THEN %DO;
WHERE dsm_&priordx = 1 AND sample_sel&n. = 1 AND sexm = 1 ;
%END;
TIME tso*c_new_&priordx._&var.(0);
FREQ &weight;
RUN;
DATA aoo1;
SET aoo;
IF CumHaz ~= .;
RUN;
DATA aoo1_&type.;
SET aoo1;
n_CumHaz = CumHaz*100;
lower_CL = (CumHaz-1.96*StdErrCumHaz)*100;
upper_CL = (CumHaz+1.96*StdErrCumHaz)*100;
%IF &type = all %THEN %DO;
w = 1;
%END;
%IF &type = female %THEN %DO;
w = 2;
%END;
%IF &type = male %THEN %DO;
w = 3;
%END;
tso1 = ROUND(tso);
RUN;
PROC PRINT DATA = aoo1_&type.; TITLE "Original";RUN;
%MEND b;
%b(type = all)
%b(type = female)
%b(type = male)
;
DATA aoo2_&k.;
SET aoo1_all aoo1_female aoo1_male;
RUN;
PROC PRINT DATA = aoo2_&k.;RUN;
DATA aoo2_&k.;
LENGTH dx $50.;
SET aoo2_&k.;
IF tso = 0 THEN DELETE;
dx = "&dx.";
RUN;
ODS PDF FILE = "mde_&var..pdf";
OPTIONS ORIENTATION = LANDSCAPE NONUMBER;
ODS ESCAPECHAR "~";
PROC FORMAT;
VALUE gfmt 1 = "All"
2 = "Females"
3 = "Males"
;
RUN;
AXIS1 LABEL = (F = DUPLEX H = 1.9 A = 90 "Cumulative Incidence per 100 People")
ORDER = (0 TO 50 BY 5)
MINOR = (N = 4)
VALUE = (H = 1.9);
AXIS2 LABEL = (F = DUPLEX H = 1.9 "Time since first diagnosis of MDE (years)")
ORDER = (0 TO 40 BY 5)
MINOR = (N = 4)
VALUE = (H = 1.9);
LEGEND1 POSITION = (INSIDE TOP LEFT) MODE = PROTECT LABEL = (H = 1.5 ' ') VALUE =(H=1.5) FRAME DOWN = 4;
SYMBOL1 CV = BLACK W = 3 LINE = 20 I = JOIN;
SYMBOL4 CV = RED W = 3 LINE = 1 I = JOIN;
SYMBOL5 CV = BLUE W = 3 LINE = 8 I = JOIN;
ODS LISTING CLOSE;
PROC GPLOT DATA = aoo2;
PLOT n_CumHaz*tso1= w /LEGEND = LEGEND1 VAXIS = AXIS1 HAXIS = AXIS2 ;
FORMAT w gfmt.;
TITLE " ";
ODS NOPTITLE;
RUN;
QUIT;
ODS LISTING;
TITLE1;
TITLE2;
QUIT;
ODS PDF CLOSE;
%MEND;