NICAR

Doug Smith's SAS code for Uplink: Hospital, deaths data records show toll of prescription drugs 

 

%Macro Poison (Year);
Data Poison&Year.;
Set Mort&Year.;
Length Manner $ 35;
Where ICD10 in ('D521', 'D590', 'D592', 'D611', 'D642',
        'E064', 'E160', 'E231', 'E242', 'E273', 'E661',
        'F11', 'F111', 'F112', 'F113', 'F114', 'F115', 'F117', 'F118', 'F119',
        'F12', 'F121', 'F122', 'F123', 'F124', 'F125', 'F127', 'F128', 'F129',
        'F13', 'F131', 'F132', 'F133', 'F134', 'F135', 'F137', 'F138', 'F139',
        'F14', 'F141', 'F142', 'F143', 'F144', 'F145', 'F147', 'F148', 'F149',
        'F15', 'F151', 'F152', 'F153', 'F154', 'F155', 'F157', 'F158', 'F159',
        'F16', 'F161', 'F162', 'F163', 'F164', 'F165', 'F167', 'F168', 'F169',
        'F17',  'F173', 'F174','F175', 'F177', 'F178', 'F179',
        'F18', 'F181', 'F182', 'F183', 'F184', 'F185', 'F187', 'F188', 'F189',
        'F19', 'F191', 'F192', 'F193', 'F194', 'F195', 'F197', 'F198', 'F199',
        'G211', 'G240', 'G251', 'G254', 'G256', 'G444', 'G620', 'G720',
        'I952',
        'J702', 'J703', 'J704',
        'K853',
        'L105', 'L270', 'L271',
        'M102', 'M320', 'M804', 'M814', 'M835', 'M871',
        'R502', 'R781', 'R782', 'R783', 'R784', 'R785',
        'X40', 'X41', 'X42', 'X43', 'X44',
       
        'X60', 'X61', 'X62', 'X63', 'X64',
        'X85',
        'Y10', 'Y11', 'Y12', 'Y13', 'Y14')
Run;
 
Data Poison&Year (Drop =  A -- N);
Set Poison&Year.;
Length Classification $ 56 Drug $ 31 RxVIllicit $ 15;
 
A = Index(RecordConditions, 'T401');
    If A > 0 then Classification = 'heroin';
 
B = Index(RecordConditions, 'T402');
    If B > 0  or D > 0 then Classification = 'opioid analgesics';
C = Index(RecordConditions, 'T403');
    If C > 0 then Classification = 'methadone';
D = Index(RecordConditions, 'T404');
    If D > 0 then Classification = 'cocaine';
E = Index(RecordConditions, 'T405');
    If E > 0 then Classification = 'cocaine';
F = Index(RecordConditions, 'T424');
    If F > 0 then Classification = 'benzodiazepine';
G = Index(RecordConditions, 'T509');
    If G > 0 then Classification = 'nonspecified';
H = Index(RecordConditions, 'T436');
    If H > 0 then Classification = 'psychostimulants';
I = Index(RecordConditions, 'T430');
    If I > 0 then Classification = 'tetracycline antidepressants';
J = Index(RecordConditions, 'T431');
    If J > 0 then Classification = 'moa antidepressants';
K= Index(RecordConditions, 'T432');
    If K > 0 then Classification = 'other antidepressants/seri/neri';
L = Index(RecordConditions, 'T433');
    If L > 0 then Classification = 'phenothiazine/neuroleptics';
M = Index(RecordConditions, 'T434');
    If M > 0 then Classification = 'butyrophenone/thiothixene neuroleptics';
N = Index(RecordConditions, 'T435');
    If N > 0 then Classification = 'unspecified antipsychotics/neuroleptics';
 
If Classification in ('tetracycline antidepressants', 'moa antidepressants',
    'unspecified antidepressants/seri/neri') then Drug = 'antidepressants';
If Classification in ('phenothiazine/neuroleptics',  'butyrophenone/thiothixene neuroleptics'
    'unspecified antipsychotics/neuroleptics') then Drug = 'antipsychotics';

If Drug in ('antidepressants', 'antipsychotics', 'opioid analgesics',
    'other antidepressants/seri/neri', 'benzodiazepine', 'methadone') then RxVIllicit = 'Rx';
If Drug in ('heroin', 'cocaine') then RxVIllicit = 'Cocaine/heroin';
If Drug = 'psychostimulants' then RxVIllicit = 'Psychostimulants';
Run;

%Mend Poison;
%Poison (Year = 00);
%Poison (Year = 01);
%Poison (Year = 02);
%Poison (Year = 03);
%Poison (Year = 04);
%Poison (Year = 05);
%Poison (Year = 06);
%Poison (Year = 07);
%Poison (Year = 08);




%Macro MortMulti (Year);

Data Mort&Year.Multi (Keep = Year ICD10 Codes Cause ID);
Set Mort.Mort&Year. ;
Retain ID 0;
ID = ID + 1;
Codes = RecordConditions;
Codes = Compbl(Codes);
X = Index(Codes, " ");
If X = 0 then do;
    Cause = Codes;
    Output;
    End;
Do while (X > 1);
    Cause = Substr(Codes, 1, X-1);
    Output;
    Codes = Substr(Codes, X + 1);
    X = Index(Codes, " ");
    End;

Run;
%MEnd MortMulti;
%MortMulti (Year = 00);
%MortMulti (Year = 01);
%MortMulti (Year = 02);
%MortMulti (Year = 03);
%MortMulti (Year = 04);
%MortMulti (Year = 05);
%MortMulti (Year = 06);
%MortMulti (Year = 07);
%MortMulti (Year = 08);

Data Mort.MortMulti;
Set Mort00Multi Mort01Multi Mort02Multi Mort03Multi Mort04Multi Mort05Multi Mort06Multi Mort07Multi Mort08Multi;
Run;

Data Mort.AllDrug;
Set Mort.MortMulti (Drop = ID );
Retain ID 1;
Length Classification $ 56 Drug $ 31 RxVIllicit $ 15;
X = Index(Codes, " ");
Y = Length(Codes);
*If X - Y = 1 then ID  = ID  + 1;
If Cause = 'T401' then Classification = 'heroin';
If Cause =  'T402' then Classification = 'opioid analgesics';
If Cause =  'T403' then Classification = 'methadone';
If Cause =  'T404' then Classification = 'cocaine';
If Cause =  'T405' then Classification = 'cocaine';
If Cause = 'T424' then Classification = 'benzodiazepine';
If Cause =  'T509' then Classification = 'nonspecified';
If Cause =  'T436' then Classification = 'psychostimulants';
If Cause =  'T430' then Classification = 'tetracycline antidepressants';
If Cause =  'T431' then Classification = 'moa antidepressants';
If Cause =  'T432' then Classification = 'other antidepressants/seri/neri';
If Cause =  'T433' then Classification = 'phenothiazine/neuroleptics';
If Cause =  'T434' then Classification = 'butyrophenone/thiothixene neuroleptics';
If Cause =  'T435' then Classification = 'unspecified antipsychotics/neuroleptics';

If Classification = '' then Classification = 'nondrug';
Drug = Classification;
If Classification in ('tetracycline antidepressants', 'moa antidepressants',
    'unspecified antidepressants/seri/neri') then Drug = 'antidepressants';
If Classification in ('phenothiazine/neuroleptics',  'butyrophenone/thiothixene neuroleptics'
    'unspecified antipsychotics/neuroleptics') then Drug = 'antipsychotics';

If Drug in ('antidepressants', 'antipsychotics', 'opioid analgesics',
    'other antidepressants/seri/neri', 'benzodiazepine', 'methadone') then RxVIllicit = 'Rx';
If Drug in ('heroin', 'cocaine') then RxVIllicit = 'Cocaine/heroin';
If Drug = 'psychostimulants' then RxVIllicit = 'Psychostimulants';
If X - Y = 1 then do;
    Output;
    ID  = ID  + 1;
    End;
Else Output;

Run;