********************************************************************** PROGRAM: CDIStoDSM4 ALCOHOL USE DISORDERS.sas PURPOSE: RECODES ALCOHOL from the CDIS TO DSM-IV ALCOHOL DIAGNOSES. GPM CREATED: 4/6/2006 MODIFIED: 4/2/2007 DISCLAIMER ----------- THIS MACRO IS PROVIDED "AS IS". THERE ARE NO WARRANTIES, EXPRESSED OR IMPLIED, AS TO MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE REGARDING THE ACCURACY OF THE MATERIALS OR CODE CONTAINED HEREIN. ----------- **********************************************************************; ******************************* USER INPUTS *****************************************************; ***LIBRARY WITH SAS DATASET CONTAINING responses to the CDIS and age variable; *** NOTE THAT CDIS VARIABLE NAMES MUST CORRESPOND TO NAMING CONVENTION; ***** DESCRIBED IN "CDIS Variable Names.txt"; libname CDISDAT "N:\Publications\DSM3to4 TEST-RETEST\Data"; %LET QDAT = CDIS_DATA; *** NAME OF DATASET WITH CDIS QUESTIONS; *** Variable names MUST be identical to those in the accompanying variable list document; *** LIBRARY FOR OUTPUT DATASET; libname DXOUT "N:\Publications\DSM3to4 TEST-RETEST\Data"; *** output dataset is called cdis_to_dsm4; ****** Macro variables for id and age variable names; %LET ID = studyid; *** UNIQUE _NUMERIC_ SUBJECT IDENTIFIER; **USED FOR MERGING AGE AND QUESTION RESPONSES; %let agevar = age; ***_numeric_ age variable. Note that age categories WILL NOT work with this code; *****************************************************************************************************************; ********************** options *************************; options nocenter nodate nonumber orientation = portrait; title1; ***************** formats ********************; proc format; value ynfmt 1 = 'NO' 5 = 'YES ' 0 = 'NA' . = 'Missing'; value dxfmt 0 = 'Neg. Dx' 1 = 'Pos. Dx'; run; PROC SORT DATA = CDISDAT.&QDAT. OUT = INDAT; BY &ID; RUN; data DSMINIT(keep = &id. &agevar. AAD4LT1-AAD4LT4 AAD4YR1 - AAD4YR4 ADD4LT1-ADD4LT7 ADD4YR1-ADD4YR7 ADD4BEG1 - ADD4BEG7 ADD4END1-ADD4END7); set INDAT; ******** DSM4 DX ******************************; *** variable name syntax: aa = alcohol abuse, AD = alcohol dependence] d4 = version DSM4 LT = lifetime , YR = one year, BEG= Sx begin date, END= SX end date 1 = symptom category 1 FOR EXAMPLE, aad4LT1 = ALCOHOL ABUSE, DSM4 DIAGNOSIS, LIFETIME, SYMPTOM #1 add4beg5 = ALCOHOL DEPENDENCE, DSM4, BEGIN DATE OF SX #5 *****; ***initialize sx components to missing; array initlist AAD4LT1-AAD4LT4 AAD4YR1 - AAD4YR4 ADD4LT1-ADD4LT7 ADD4YR1-ADD4YR7 ADD4BEG1 - ADD4BEG7 ADD4END1-ADD4END7 ; do over initlist; initlist = .; end; ***** ALCOHOL ABUSE ******************; **** Note that there is no way to ascertain if these symtoms occurred repeatedly within a 12 month period ****; **** abuse criteria 1 ****; IF (M06 = 5 AND M06A = 5) OR M13= 5 OR M13A = 5 THEN DO; *** SUBJECT MEETS ANY OF ABUSE CRITERIA 1 ***; AAD4LT1 =1; *** LIFETIME FOR CRITERIA 1 +1; IF M13AC <6 THEN AAD4YR1=1; *** IF AVAILABLE RECENCY INFO POSITIVE FOR LAST YEAR THEN 1 YR CRITERIA +1; **** RECENCY ONLY IF M13 QUESTION IS AFFIRMATIVE ***; END; ****Abuse criteria 2 *****; IF (M18 = 5 AND M18AA = 5) OR M19 = 5 THEN DO; AAD4LT2=1; IF M18C < 6 OR M19C <6 THEN AAD4YR2 =1; END; **** Abuse criteria 3 ****; IF M17 = 5 AND M17AA = 5 THEN DO; AAD4LT3 =1; IF M17C < 6 THEN AAD4YR3 =1; END; **** Abuse criteria 4 ****; IF M15 = 5 AND M16 = 5 THEN DO; AAD4LT4=1; IF M15C < 6 THEN AAD4YR4 =1; END; ************************ ALCOHOL DEPENDENCE *****************************; ************* DEPENDENCE SYMTOM 1 *************; IF M07 = 5 OR ( M07A = 5 AND M07B = 5) THEN DO; ADD4LT1 =1; ADD4BEG1 = MIN (M07AB ,AGE ); ADD4END1 = AGE; *** FUDGE FACTOR: ONCE YOU DEVELOP TOLERANCE IT IS PERMANENT AND THE RECENCY IS THE CURRENT AGE ***; END; ************** DEPENDENCE SYMPTOM 2 ***************; IF (M21 = 5 AND M21AA = 5) OR M22 = 5 OR (( M23 = 5 or M23A = 5 OR M23B = 5) AND M23C = 5) THEN DO; ADD4LT2=1; IF M21C <6 OR M22C < 6 OR M23BC < 6 THEN ADD4YR2 =1; ADD4BEG2 = MIN(M21B, M22B, M23BB ,AGE); ADD4END2 = MIN(max(M21D, M22D, M23BD), AGE); END; **** DEPENDENCE SYMTOM 3 **************; IF M08 = 5 THEN DO; ADD4LT3 =1; IF M08C <6 THEN ADD4YR3=1; ADD4BEG3 = MIN (M08B,AGE); ***ONSET < 1 YEAR AGO YIELD M08B = . ***; ADD4END3 = MIN(M08D,AGE); ***RECENCY LESS THEN ONE YEAR AGO YIELD M08D =. ***; END; ********* DEPENDENCE SYMTOM 4 ********************; IF M09 = 5 OR M09C = 5 OR (M10=5 AND M10B = 5) THEN DO; ADD4LT4 =1; IF M10_REC < 6 THEN ADD4YR4=1; if (M09 = 5 OR M09C=5 )AND M10 NE 5 THEN DO; ADD4BEG4 = 1; ADD4END4 = AGE; END; ELSE DO; ADD4BEG4 = MIN(M10_OAGE,AGE); ADD4END4 = MIN(M10_RAGE,AGE); END; END; ****** DEPENDENCE SYMPTOM 5 ***************; IF M11 = 5 AND M11A = 5 THEN DO; ADD4LT5 =1; IF M11_REC < 6 THEN ADD4YR5 =1; ADD4BEG5 = MIN(M11_OAGE, AGE); ADD4END5 = MIN(M11_RAGE,AGE); END; ****** DEPENDENCE SYMPTOM 6 *************; IF M12 = 5 AND M12A = 5 THEN DO; ADD4LT6=1; IF M12_REC < 6 THEN ADD4YR6=1; ADD4BEG6 = MIN(M12_OAGE, AGE); ADD4END6 = MIN(M12_RAGE,AGE); END; ******* DEPENDENCE SYMTOM 7 *****; IF M26 = 5 OR M27 = 5 OR M29AA = 5 THEN DO; ADD4LT7=1; IF M27C < 6 OR M28C < 6 OR M29C < 6 THEN ADD4YR7=1; ADD4BEG7 = MIN(AGE, M25B, M27B, M28B, M29B); ADD4END7 = MIN(AGE, max(M27D, M28D, M29D) ); END; RUN; **** get data set with all seven choose three combos ****; ods output plan = combs; proc plan; factors comboid = 35 ordered var = 3 of 7 comb; run; quit; ods output close; %macro depend; ***** This macro cycles through all 7 choose 3 (=35) sets of three symptoms and sees if all symptoms per set occur overlap in time****; *** Start and end dates conform to earliest or latest symtpom manifest from the set of three ***; proc delete data = master; run; data master; retain &id. alcdep .; run; %do z = 1 %to 35; proc delete data = depinit; run; proc delete data = depinit2; run; proc sql; create table depinit as select d.*, c.* from DSMINIT as d, combs(where = (comboid = &z.)) as c; quit; data depinit2; set depinit; ****** ALCOHOL DEPENDENCE SYMPTOMS******; array begin{7} ADD4BEG1 - ADD4BEG7; array end{7} ADD4END1 - ADD4END7; if nmiss(BEGIN[var1], BEGIN[var2], BEGIN[var3]) = 0 then do; *** if all startdates are non-missing then determine if overlap occurs; **else skip to next combo indexed by &z; ***** if the latest begin date for a symtom is earlier than the earliest end date, then the three symptoms overlap and dependence is positive***; IF MAX(of BEGIN[var1], BEGIN[var2], BEGIN[var3]) <= MIN(of END[var1], END[var2], END[var3]) THEN alcdep = 1; end; RUN; proc append data = depinit2(keep = &id. alcdep ) base = master; run; %end; %mend; %depend; *** sum the number of combinations of three symtoms that co-occur; proc summary data = master nway sum; var alcdep ; class &id.; output out = depsx sum = alcdepsx ; run; ****** get final diagnoses ****; data d3tod4_P; merge DSMINIT depsx(drop = _type_ _freq_); by &id.; ***** This array format is not necessary, but facilitates extension to drug use disorders, which is still under testing; ARRAY DX[4] AD_DSM4_LT AD_DSM4_YR AA_DSM4_LT AA_DSM4_YR ; ARRAY ABUSEONEYR[4] AAD4YR1 AAD4YR2 AAD4YR3 AAD4YR4 ; ARRAY ABUSELT{4} AAD4LT1 AAD4LT2 AAD4LT3 AAD4LT4 ; ARRAY DEPONEYR[7] ADD4YR1 ADD4YR2 ADD4YR3 ADD4YR4 ADD4YR5 ADD4YR6 ADD4YR7 ; **** CONSTRUCT FINAL SET OF DIAGNOSES; *** NOTE THAT DSM-4 REQUIRES THAT DEPENDENCE ALWAYS SUPERCEDES ABUSE****; if ALCDEPSX then do; dx[1] = 1; DX[2] = 0; dx[3] = 0; DX[4] = 0; *** if one or more combo of three sx co-occur, then lifetime dependence = 1 and all abuse dx set to 0; if sum(of DEPONEYR[1], DEPONEYR[2], DEPONEYR[3], DEPONEYR[4], DEPONEYR[5], DEPONEYR[6], DEPONEYR[7] ) > 0 THEN DX[2] = 1; *** if any dependence sx in last year, then one year is one; end; ELSE DO; dx[1] = 0; DX[2] = 0; dx[3] = 0; DX[4] = 0; IF SUM(OF ABUSELT[1], ABUSELT[2], ABUSELT[3], ABUSELT[4]) > 0 then do; ***if any lifetime abuse sx, then lt abuse = 1; dx[3] = 1; if SUM(OF ABUSEONEYR[1], ABUSEONEYR[2], ABUSEONEYR[3], ABUSEONEYR[4] ) > 0 THEN DX[4] = 1; *** if any abuse sx in last year, then one year abuse = 1; END; END; *********** ALLOW FOR POSSIBILITY OF ONE YEAR ABUSE IF NO ONE YEAR DEPENDENCE **********; if SUM(OF ABUSEONEYR[1], ABUSEONEYR[2], ABUSEONEYR[3], ABUSEONEYR[4] ) > 0 AND DX[2] = 0 THEN DX[4] = 1; label ad_dsm4_lt = "Alc Dependence DSM-IV Lifetime (0=NoDx, 1=Pos.Dx)" ad_dsm4_yr = "Alc Dependence DSM-IV One year (0=NoDx, 1=Pos.Dx)" aa_dsm4_lt = "Alc Abuse DSM-IV Lifetime (0=NoDx, 1=Pos.Dx)" aa_dsm4_yr = "Alc Abuse DSM-IV One year (0=NoDx, 1=Pos.Dx)"; RUN; Data dxout.cdis_to_dsm4; set d3tod4_P(keep = &id. AD_DSM4_LT AD_DSM4_YR AA_DSM4_LT AA_DSM4_YR ); *** for each diagnosis a 0 = 'negative', 1 = 'Positive'; run; proc freq data = dxout.cdis_to_dsm4; tables AD_DSM4_LT AD_DSM4_YR AA_DSM4_LT AA_DSM4_YR; run;