- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I have a block of code that is quite repetitive, as it processes similar tasks across multiple datasets. To streamline this, I’m trying to create a macro, medpar_analyis to loop through the dataset medpar for the years 2019 to 2021.
However, when I run the macro, I encounter the following error:
ERROR 161-185: No matching DO/SELECT statement.
e error points to a specific line of code within the macro. Interestingly, when I run the same code for an individual dataset (e.g., medpar_2019), it compiles and executes without any issues. This leads me to believe the issue lies in how the macro handles loops or iterates over the datasets.
I’m unsure where the unmatched DO loop or SELECT statement might be causing the error. Could you help identify the problem and suggest a solution?
%macro medpar_analysis;
%do years=2019 %to 2021;
data output.merged_medpar_mbsf_pdpn_&years._1;
set output.merged_medpar_mbsf_pdpn_&years._1;
array DGNS[25] $ DGNS_1_CD -- DGNS_25_CD;
DEPRESSION_MEDPAR = .;
NONALZH_DEMEN_MEDPAR = .;
ALZH_MEDPAR = .;
PNEUMO_MEDPAR = .;
hf_medpar =.;
PRKNSN_MEDPAR = .;
STROKE_TIA_MEDPAR = .;
ANXI_MEDICARE_MEDPAR =.;
BIPOLAR_MEDPAR = .;
TBI_MEDPAR = .;
DRUGS_MEDPAR = .;
SCHIOT_MEDPAR = .;
OUD_ANY_MEDPAR = .;
array depression_codes[50] $8 _temporary_ ('F0631', 'F0632', 'F310', 'F3110', 'F3111', 'F3112', 'F3113',
'F312', 'F3130', 'F3131', 'F3132', 'F314', 'F315', 'F3160',
'F3161', 'F3162', 'F3163', 'F3164', 'F3171', 'F3173', 'F3175',
'F3176', 'F3177', 'F3178', 'F3181', 'F3189', 'F319', 'F320',
'F321', 'F322', 'F323', 'F324', 'F325', 'F328', 'F3289',
'F329', 'F32A', 'F330', 'F331', 'F332', 'F333', 'F3340',
'F3341', 'F3342', 'F338', 'F339', 'F340', 'F341', 'F4321', 'F4323');
array nonalzhimers_codes[84] $8 _temporary_ ('F0150', 'F0151', 'F01511', 'F01518', 'F0152', 'F0153', 'F0154',
'F01A0', 'F01A11', 'F01A18', 'F01A2', 'F01A3', 'F01A4', 'F01B0',
'F01B11', 'F01B18', 'F01B2', 'F01B3', 'F01B4', 'F01C0', 'F01C11',
'F01C18', 'F01C2', 'F01C3', 'F01C4', 'F0280', 'F0281', 'F02811',
'F02818', 'F0282', 'F0283', 'F0284', 'F02A0', 'F02A11', 'F02A18',
'F02A2', 'F02A3', 'F02A4', 'F02B0', 'F02B11', 'F02B18', 'F02B2',
'F02B3', 'F02B4', 'F02C0', 'F02C11', 'F02C18', 'F02C2', 'F02C3',
'F02C4', 'F0390', 'F0391', 'F03911', 'F03918', 'F0392', 'F0393',
'F0394', 'F03A0', 'F03A11', 'F03A18', 'F03A2', 'F03A3', 'F03A4',
'F03B0', 'F03B11', 'F03B18', 'F03B2', 'F03B3', 'F03B4', 'F03C0',
'F03C11', 'F03C18', 'F03C2', 'F03C3', 'F03C4', 'F05', 'G138',
'G3101', 'G3109', 'G311', 'G312', 'G3183', 'G94', 'R4181');
array alzhimers_codes[4] $8 _temporary_ ('G300', 'G301','G308', 'G309');
do i = 1 to dim(DGNS);
if not missing(DGNS[i]) then do;
if strip(DGNS[i]) in alzhimers_codes then ALZH_MEDPAR = 1;
end;
end;
/* Assign 0 to ALZH_MEDPAR for other diagnosis codes */
do i = 1 to dim(DGNS);
if missing(ALZH_MEDPAR) then do;
if strip(DGNS[i]) in depression_codes then ALZH_MEDPAR = 0;
if strip(DGNS[i]) in nonalzhimers_codes then ALZH_MEDPAR = 0;
if strip(DGNS[i]) in pneumonia_codes then ALZH_MEDPAR = 0;
if strip(DGNS[i]) in hf_codes then ALZH_MEDPAR = 0;
if strip(DGNS[i]) in prknsn_codes then ALZH_MEDPAR = 0;
if strip(DGNS[i]) in stroke_codes then ALZH_MEDPAR = 0;
if strip(DGNS[i]) in stroke_exclusion_codes then ALZH_MEDPAR = 0;
if strip(DGNS[i]) in anxiety_codes then ALZH_MEDPAR = 0;
if strip(DGNS[i]) in bipolar_codes then ALZH_MEDPAR = 0;
if strip(DGNS[i]) in TBI_codes then ALZH_MEDPAR = 0;
if strip(DGNS[i]) in DRUG_USE_CODES then ALZH_MEDPAR = 0;
if strip(DGNS[i]) in PSYCH_CODES then ALZH_MEDPAR = 0;
if strip(DGNS[i]) in OUD_CODES then ALZH_MEDPAR = 0;
end;
end;
/* Assign -9 to ALZH_MEDPAR if all DGNS values are missing */
do i = 1 to dim(DGNS);
if missing(ALZH_MEDPAR) then do;
if missing(DGNS[i]) then ALZH_MEDPAR = -9;
end;
end;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You are missing a %end