<?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 Re: Need help with Macro Do Loop and Proc Report in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-Macro-Do-Loop-and-Proc-Report/m-p/679507#M205191</link>
    <description>&lt;P&gt;The log showing submitted lines but no results is a typical behavior after some of the common syntax errors when learning the macro language. Creating something with unbalanced quotes, parentheses, or improperly ended statements can place the system into an unsteady state.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You likely have to close the SAS session and restart.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would suggest that until you get experience with the macro language that you always set OPTIONS MPRINT; before running any macro and then reading the log closely. Almost any warning is something to be investigated. Also with MPRINT on then any messages appear in better relation to the issue instead of a series of notes at the end of the macro execution.&lt;/P&gt;</description>
    <pubDate>Wed, 26 Aug 2020 14:48:30 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2020-08-26T14:48:30Z</dc:date>
    <item>
      <title>Need help with Macro Do Loop and Proc Report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-Macro-Do-Loop-and-Proc-Report/m-p/679490#M205186</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I'm trying to create make a Macro Do Loop that will create individual reports like the one attached for the Proc Print procedure. But every time I run the code below, it just gets put into the log but no results are printed:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro patients;&lt;BR /&gt;%do i=1101 %to i=1109;&lt;BR /&gt;proc report data=Report3.Clinical3Sort nofs;&lt;BR /&gt;where PATIENT_ID=&amp;amp;i.;&lt;BR /&gt;title "Blood Pressure Med Study";&lt;BR /&gt;column PATIENT_ID DRUG SEX VISIT_DATE SYSTOLIC DIASTOLIC FEVER NAUSEA RASH;&lt;BR /&gt;define PATIENT_ID / group;&lt;BR /&gt;define DRUG / group;&lt;BR /&gt;define SEX / group;&lt;BR /&gt;define VISIT_DATE / display;&lt;BR /&gt;define SYSTOLIC / display;&lt;BR /&gt;define DIASTOLIC / display;&lt;BR /&gt;define FEVER / display;&lt;BR /&gt;define NAUSEA / display;&lt;BR /&gt;define RASH / display;&lt;BR /&gt;run;&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;/P&gt;&lt;P&gt;%patients;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is appreciated&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Aug 2020 14:06:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-Macro-Do-Loop-and-Proc-Report/m-p/679490#M205186</guid>
      <dc:creator>rishabhns</dc:creator>
      <dc:date>2020-08-26T14:06:23Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with Macro Do Loop and Proc Report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-Macro-Do-Loop-and-Proc-Report/m-p/679497#M205189</link>
      <description>&lt;P&gt;You don't need a macro for this - just a BY PATIENT_ID statement.&amp;nbsp; If your dataset Report3.Clinical3Sort is already sorted by ID, you can just do this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report data=Report3.Clinical3Sort nofs;
  by PATIENT_ID;
  where patient_id between 1101 and 1109;
  title "Blood Pressure Med Study";
  column PATIENT_ID DRUG SEX VISIT_DATE SYSTOLIC DIASTOLIC FEVER   NAUSEA RASH;
  define PATIENT_ID / group;
  define DRUG / group;
  define SEX / group;
  define VISIT_DATE / display;
  define SYSTOLIC / display;
  define DIASTOLIC / display;
  define FEVER / display;
  define NAUSEA / display;
  define RASH / display;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And if the data aren't sorted by ID, just create a sorted dataset to submit to proc report:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=Report3.Clinical3Sort  out=temp;
  where patient_id between 1101 and 1109;
  by patient_id;
run;

proc report data=temp  nofs;
  by patient_id;
.......
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Aug 2020 14:21:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-Macro-Do-Loop-and-Proc-Report/m-p/679497#M205189</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-08-26T14:21:26Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with Macro Do Loop and Proc Report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-Macro-Do-Loop-and-Proc-Report/m-p/679507#M205191</link>
      <description>&lt;P&gt;The log showing submitted lines but no results is a typical behavior after some of the common syntax errors when learning the macro language. Creating something with unbalanced quotes, parentheses, or improperly ended statements can place the system into an unsteady state.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You likely have to close the SAS session and restart.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would suggest that until you get experience with the macro language that you always set OPTIONS MPRINT; before running any macro and then reading the log closely. Almost any warning is something to be investigated. Also with MPRINT on then any messages appear in better relation to the issue instead of a series of notes at the end of the macro execution.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Aug 2020 14:48:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-Macro-Do-Loop-and-Proc-Report/m-p/679507#M205191</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-08-26T14:48:30Z</dc:date>
    </item>
  </channel>
</rss>

