<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Troubleshooting a Macro Error: Resolving 'No Matching DO/SELECT Statement' in SAS Loop for Multiple in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Troubleshooting-a-Macro-Error-Resolving-No-Matching-DO-SELECT/m-p/955484#M373156</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;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&amp;nbsp; medpar for the years 2019 to 2021.&lt;/P&gt;&lt;P&gt;However, when I run the macro, I encounter the following error:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;ERROR&lt;/SPAN&gt; &lt;SPAN class=""&gt;161&lt;/SPAN&gt;-&lt;SPAN class=""&gt;185&lt;/SPAN&gt;: No matching &lt;SPAN class=""&gt;DO&lt;/SPAN&gt;/&lt;SPAN class=""&gt;SELECT&lt;/SPAN&gt; statement.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;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?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%macro medpar_analysis;&lt;BR /&gt;%do years=2019 %to 2021;&lt;/P&gt;&lt;P&gt;data output.merged_medpar_mbsf_pdpn_&amp;amp;years._1;&lt;BR /&gt;set output.merged_medpar_mbsf_pdpn_&amp;amp;years._1;&lt;BR /&gt;array DGNS[25] $ DGNS_1_CD -- DGNS_25_CD;&lt;BR /&gt;DEPRESSION_MEDPAR = .;&lt;BR /&gt;NONALZH_DEMEN_MEDPAR = .;&lt;BR /&gt;ALZH_MEDPAR = .;&lt;BR /&gt;PNEUMO_MEDPAR = .;&lt;BR /&gt;hf_medpar =.;&lt;BR /&gt;PRKNSN_MEDPAR = .;&lt;BR /&gt;STROKE_TIA_MEDPAR = .;&lt;BR /&gt;ANXI_MEDICARE_MEDPAR =.;&lt;BR /&gt;BIPOLAR_MEDPAR = .;&lt;BR /&gt;TBI_MEDPAR = .;&lt;BR /&gt;DRUGS_MEDPAR = .;&lt;BR /&gt;SCHIOT_MEDPAR = .;&lt;BR /&gt;OUD_ANY_MEDPAR = .;&lt;/P&gt;&lt;P&gt;array depression_codes[50] $8 _temporary_ ('F0631', 'F0632', 'F310', 'F3110', 'F3111', 'F3112', 'F3113',&lt;BR /&gt;'F312', 'F3130', 'F3131', 'F3132', 'F314', 'F315', 'F3160',&lt;BR /&gt;'F3161', 'F3162', 'F3163', 'F3164', 'F3171', 'F3173', 'F3175',&lt;BR /&gt;'F3176', 'F3177', 'F3178', 'F3181', 'F3189', 'F319', 'F320',&lt;BR /&gt;'F321', 'F322', 'F323', 'F324', 'F325', 'F328', 'F3289',&lt;BR /&gt;'F329', 'F32A', 'F330', 'F331', 'F332', 'F333', 'F3340',&lt;BR /&gt;'F3341', 'F3342', 'F338', 'F339', 'F340', 'F341', 'F4321', 'F4323');&lt;/P&gt;&lt;P&gt;array nonalzhimers_codes[84] $8 _temporary_ ('F0150', 'F0151', 'F01511', 'F01518', 'F0152', 'F0153', 'F0154',&lt;BR /&gt;'F01A0', 'F01A11', 'F01A18', 'F01A2', 'F01A3', 'F01A4', 'F01B0',&lt;BR /&gt;'F01B11', 'F01B18', 'F01B2', 'F01B3', 'F01B4', 'F01C0', 'F01C11',&lt;BR /&gt;'F01C18', 'F01C2', 'F01C3', 'F01C4', 'F0280', 'F0281', 'F02811',&lt;BR /&gt;'F02818', 'F0282', 'F0283', 'F0284', 'F02A0', 'F02A11', 'F02A18',&lt;BR /&gt;'F02A2', 'F02A3', 'F02A4', 'F02B0', 'F02B11', 'F02B18', 'F02B2',&lt;BR /&gt;'F02B3', 'F02B4', 'F02C0', 'F02C11', 'F02C18', 'F02C2', 'F02C3',&lt;BR /&gt;'F02C4', 'F0390', 'F0391', 'F03911', 'F03918', 'F0392', 'F0393',&lt;BR /&gt;'F0394', 'F03A0', 'F03A11', 'F03A18', 'F03A2', 'F03A3', 'F03A4',&lt;BR /&gt;'F03B0', 'F03B11', 'F03B18', 'F03B2', 'F03B3', 'F03B4', 'F03C0',&lt;BR /&gt;'F03C11', 'F03C18', 'F03C2', 'F03C3', 'F03C4', 'F05', 'G138',&lt;BR /&gt;'G3101', 'G3109', 'G311', 'G312', 'G3183', 'G94', 'R4181');&lt;/P&gt;&lt;P&gt;array alzhimers_codes[4] $8 _temporary_ ('G300', 'G301','G308', 'G309');&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;do i = 1 to dim(DGNS);&lt;BR /&gt;if not missing(DGNS[i]) then do;&lt;BR /&gt;if strip(DGNS[i]) in alzhimers_codes then ALZH_MEDPAR = 1;&lt;BR /&gt;end;&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;/* Assign 0 to ALZH_MEDPAR for other diagnosis codes */&lt;BR /&gt;do i = 1 to dim(DGNS);&lt;BR /&gt;if missing(ALZH_MEDPAR) then do;&lt;BR /&gt;if strip(DGNS[i]) in depression_codes then ALZH_MEDPAR = 0;&lt;BR /&gt;if strip(DGNS[i]) in nonalzhimers_codes then ALZH_MEDPAR = 0;&lt;BR /&gt;if strip(DGNS[i]) in pneumonia_codes then ALZH_MEDPAR = 0;&lt;BR /&gt;if strip(DGNS[i]) in hf_codes then ALZH_MEDPAR = 0;&lt;BR /&gt;if strip(DGNS[i]) in prknsn_codes then ALZH_MEDPAR = 0;&lt;BR /&gt;if strip(DGNS[i]) in stroke_codes then ALZH_MEDPAR = 0;&lt;BR /&gt;if strip(DGNS[i]) in stroke_exclusion_codes then ALZH_MEDPAR = 0;&lt;BR /&gt;if strip(DGNS[i]) in anxiety_codes then ALZH_MEDPAR = 0;&lt;BR /&gt;if strip(DGNS[i]) in bipolar_codes then ALZH_MEDPAR = 0;&lt;BR /&gt;if strip(DGNS[i]) in TBI_codes then ALZH_MEDPAR = 0;&lt;BR /&gt;if strip(DGNS[i]) in DRUG_USE_CODES then ALZH_MEDPAR = 0;&lt;BR /&gt;if strip(DGNS[i]) in PSYCH_CODES then ALZH_MEDPAR = 0;&lt;BR /&gt;if strip(DGNS[i]) in OUD_CODES then ALZH_MEDPAR = 0;&lt;BR /&gt;end;&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;/* Assign -9 to ALZH_MEDPAR if all DGNS values are missing */&lt;BR /&gt;do i = 1 to dim(DGNS);&lt;BR /&gt;if missing(ALZH_MEDPAR) then do;&lt;BR /&gt;if missing(DGNS[i]) then ALZH_MEDPAR = -9;&lt;BR /&gt;end;&lt;BR /&gt;end;&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
    <pubDate>Wed, 08 Jan 2025 15:54:19 GMT</pubDate>
    <dc:creator>LuisMijares</dc:creator>
    <dc:date>2025-01-08T15:54:19Z</dc:date>
    <item>
      <title>Troubleshooting a Macro Error: Resolving 'No Matching DO/SELECT Statement' in SAS Loop for Multiple</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Troubleshooting-a-Macro-Error-Resolving-No-Matching-DO-SELECT/m-p/955484#M373156</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;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&amp;nbsp; medpar for the years 2019 to 2021.&lt;/P&gt;&lt;P&gt;However, when I run the macro, I encounter the following error:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;ERROR&lt;/SPAN&gt; &lt;SPAN class=""&gt;161&lt;/SPAN&gt;-&lt;SPAN class=""&gt;185&lt;/SPAN&gt;: No matching &lt;SPAN class=""&gt;DO&lt;/SPAN&gt;/&lt;SPAN class=""&gt;SELECT&lt;/SPAN&gt; statement.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;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?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%macro medpar_analysis;&lt;BR /&gt;%do years=2019 %to 2021;&lt;/P&gt;&lt;P&gt;data output.merged_medpar_mbsf_pdpn_&amp;amp;years._1;&lt;BR /&gt;set output.merged_medpar_mbsf_pdpn_&amp;amp;years._1;&lt;BR /&gt;array DGNS[25] $ DGNS_1_CD -- DGNS_25_CD;&lt;BR /&gt;DEPRESSION_MEDPAR = .;&lt;BR /&gt;NONALZH_DEMEN_MEDPAR = .;&lt;BR /&gt;ALZH_MEDPAR = .;&lt;BR /&gt;PNEUMO_MEDPAR = .;&lt;BR /&gt;hf_medpar =.;&lt;BR /&gt;PRKNSN_MEDPAR = .;&lt;BR /&gt;STROKE_TIA_MEDPAR = .;&lt;BR /&gt;ANXI_MEDICARE_MEDPAR =.;&lt;BR /&gt;BIPOLAR_MEDPAR = .;&lt;BR /&gt;TBI_MEDPAR = .;&lt;BR /&gt;DRUGS_MEDPAR = .;&lt;BR /&gt;SCHIOT_MEDPAR = .;&lt;BR /&gt;OUD_ANY_MEDPAR = .;&lt;/P&gt;&lt;P&gt;array depression_codes[50] $8 _temporary_ ('F0631', 'F0632', 'F310', 'F3110', 'F3111', 'F3112', 'F3113',&lt;BR /&gt;'F312', 'F3130', 'F3131', 'F3132', 'F314', 'F315', 'F3160',&lt;BR /&gt;'F3161', 'F3162', 'F3163', 'F3164', 'F3171', 'F3173', 'F3175',&lt;BR /&gt;'F3176', 'F3177', 'F3178', 'F3181', 'F3189', 'F319', 'F320',&lt;BR /&gt;'F321', 'F322', 'F323', 'F324', 'F325', 'F328', 'F3289',&lt;BR /&gt;'F329', 'F32A', 'F330', 'F331', 'F332', 'F333', 'F3340',&lt;BR /&gt;'F3341', 'F3342', 'F338', 'F339', 'F340', 'F341', 'F4321', 'F4323');&lt;/P&gt;&lt;P&gt;array nonalzhimers_codes[84] $8 _temporary_ ('F0150', 'F0151', 'F01511', 'F01518', 'F0152', 'F0153', 'F0154',&lt;BR /&gt;'F01A0', 'F01A11', 'F01A18', 'F01A2', 'F01A3', 'F01A4', 'F01B0',&lt;BR /&gt;'F01B11', 'F01B18', 'F01B2', 'F01B3', 'F01B4', 'F01C0', 'F01C11',&lt;BR /&gt;'F01C18', 'F01C2', 'F01C3', 'F01C4', 'F0280', 'F0281', 'F02811',&lt;BR /&gt;'F02818', 'F0282', 'F0283', 'F0284', 'F02A0', 'F02A11', 'F02A18',&lt;BR /&gt;'F02A2', 'F02A3', 'F02A4', 'F02B0', 'F02B11', 'F02B18', 'F02B2',&lt;BR /&gt;'F02B3', 'F02B4', 'F02C0', 'F02C11', 'F02C18', 'F02C2', 'F02C3',&lt;BR /&gt;'F02C4', 'F0390', 'F0391', 'F03911', 'F03918', 'F0392', 'F0393',&lt;BR /&gt;'F0394', 'F03A0', 'F03A11', 'F03A18', 'F03A2', 'F03A3', 'F03A4',&lt;BR /&gt;'F03B0', 'F03B11', 'F03B18', 'F03B2', 'F03B3', 'F03B4', 'F03C0',&lt;BR /&gt;'F03C11', 'F03C18', 'F03C2', 'F03C3', 'F03C4', 'F05', 'G138',&lt;BR /&gt;'G3101', 'G3109', 'G311', 'G312', 'G3183', 'G94', 'R4181');&lt;/P&gt;&lt;P&gt;array alzhimers_codes[4] $8 _temporary_ ('G300', 'G301','G308', 'G309');&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;do i = 1 to dim(DGNS);&lt;BR /&gt;if not missing(DGNS[i]) then do;&lt;BR /&gt;if strip(DGNS[i]) in alzhimers_codes then ALZH_MEDPAR = 1;&lt;BR /&gt;end;&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;/* Assign 0 to ALZH_MEDPAR for other diagnosis codes */&lt;BR /&gt;do i = 1 to dim(DGNS);&lt;BR /&gt;if missing(ALZH_MEDPAR) then do;&lt;BR /&gt;if strip(DGNS[i]) in depression_codes then ALZH_MEDPAR = 0;&lt;BR /&gt;if strip(DGNS[i]) in nonalzhimers_codes then ALZH_MEDPAR = 0;&lt;BR /&gt;if strip(DGNS[i]) in pneumonia_codes then ALZH_MEDPAR = 0;&lt;BR /&gt;if strip(DGNS[i]) in hf_codes then ALZH_MEDPAR = 0;&lt;BR /&gt;if strip(DGNS[i]) in prknsn_codes then ALZH_MEDPAR = 0;&lt;BR /&gt;if strip(DGNS[i]) in stroke_codes then ALZH_MEDPAR = 0;&lt;BR /&gt;if strip(DGNS[i]) in stroke_exclusion_codes then ALZH_MEDPAR = 0;&lt;BR /&gt;if strip(DGNS[i]) in anxiety_codes then ALZH_MEDPAR = 0;&lt;BR /&gt;if strip(DGNS[i]) in bipolar_codes then ALZH_MEDPAR = 0;&lt;BR /&gt;if strip(DGNS[i]) in TBI_codes then ALZH_MEDPAR = 0;&lt;BR /&gt;if strip(DGNS[i]) in DRUG_USE_CODES then ALZH_MEDPAR = 0;&lt;BR /&gt;if strip(DGNS[i]) in PSYCH_CODES then ALZH_MEDPAR = 0;&lt;BR /&gt;if strip(DGNS[i]) in OUD_CODES then ALZH_MEDPAR = 0;&lt;BR /&gt;end;&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;/* Assign -9 to ALZH_MEDPAR if all DGNS values are missing */&lt;BR /&gt;do i = 1 to dim(DGNS);&lt;BR /&gt;if missing(ALZH_MEDPAR) then do;&lt;BR /&gt;if missing(DGNS[i]) then ALZH_MEDPAR = -9;&lt;BR /&gt;end;&lt;BR /&gt;end;&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Wed, 08 Jan 2025 15:54:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Troubleshooting-a-Macro-Error-Resolving-No-Matching-DO-SELECT/m-p/955484#M373156</guid>
      <dc:creator>LuisMijares</dc:creator>
      <dc:date>2025-01-08T15:54:19Z</dc:date>
    </item>
    <item>
      <title>Re: Troubleshooting a Macro Error: Resolving 'No Matching DO/SELECT Statement' in SAS Loop for Multi</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Troubleshooting-a-Macro-Error-Resolving-No-Matching-DO-SELECT/m-p/955598#M373195</link>
      <description>&lt;P&gt;You are missing a %end&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jan 2025 08:26:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Troubleshooting-a-Macro-Error-Resolving-No-Matching-DO-SELECT/m-p/955598#M373195</guid>
      <dc:creator>rudfaden</dc:creator>
      <dc:date>2025-01-09T08:26:02Z</dc:date>
    </item>
  </channel>
</rss>

