<?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 Looping a PROC PRINT in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Looping-a-PROC-PRINT/m-p/28377#M6586</link>
    <description>Hello everyone, I am new to SAS and I'm wondering how I could loop a procedure (if possible that is).&lt;BR /&gt;
&lt;BR /&gt;
I have written this:&lt;BR /&gt;
&lt;BR /&gt;
options fmtsearch= (projet.formats) ;&lt;BR /&gt;
&lt;B&gt;PROC PRINT&lt;/B&gt; data=PROJET.CORAIL noobs;&lt;BR /&gt;
	DO Region=1 to 6;&lt;BR /&gt;
	VAR Economic_Health   Risk   Population;&lt;BR /&gt;
	FORMAT Region Region.;&lt;BR /&gt;
	FORMAT Risk Risk.;&lt;BR /&gt;
	FORMAT Economic_Health Economic_Health.;&lt;BR /&gt;
	END;&lt;BR /&gt;
&lt;B&gt;RUN&lt;/B&gt;;&lt;BR /&gt;
&lt;BR /&gt;
But I get an error which says "Statement is not valid or it is used out of proper order". I can obtain a right result if I remove the DO statement and put a WHERE Region=1 statement but this would rewriting the procedure 5 times, which doesn't seem very practical in my opinion. What are the possible alternative?&lt;BR /&gt;
&lt;BR /&gt;
Thank-you in advance.</description>
    <pubDate>Thu, 10 Dec 2009 14:20:23 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2009-12-10T14:20:23Z</dc:date>
    <item>
      <title>Looping a PROC PRINT</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Looping-a-PROC-PRINT/m-p/28377#M6586</link>
      <description>Hello everyone, I am new to SAS and I'm wondering how I could loop a procedure (if possible that is).&lt;BR /&gt;
&lt;BR /&gt;
I have written this:&lt;BR /&gt;
&lt;BR /&gt;
options fmtsearch= (projet.formats) ;&lt;BR /&gt;
&lt;B&gt;PROC PRINT&lt;/B&gt; data=PROJET.CORAIL noobs;&lt;BR /&gt;
	DO Region=1 to 6;&lt;BR /&gt;
	VAR Economic_Health   Risk   Population;&lt;BR /&gt;
	FORMAT Region Region.;&lt;BR /&gt;
	FORMAT Risk Risk.;&lt;BR /&gt;
	FORMAT Economic_Health Economic_Health.;&lt;BR /&gt;
	END;&lt;BR /&gt;
&lt;B&gt;RUN&lt;/B&gt;;&lt;BR /&gt;
&lt;BR /&gt;
But I get an error which says "Statement is not valid or it is used out of proper order". I can obtain a right result if I remove the DO statement and put a WHERE Region=1 statement but this would rewriting the procedure 5 times, which doesn't seem very practical in my opinion. What are the possible alternative?&lt;BR /&gt;
&lt;BR /&gt;
Thank-you in advance.</description>
      <pubDate>Thu, 10 Dec 2009 14:20:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Looping-a-PROC-PRINT/m-p/28377#M6586</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-12-10T14:20:23Z</dc:date>
    </item>
    <item>
      <title>Re: Looping a PROC PRINT</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Looping-a-PROC-PRINT/m-p/28378#M6587</link>
      <description>A couple of options:&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
PROC PRINT data=PROJET.CORAIL noobs;&lt;BR /&gt;
by region;&lt;BR /&gt;
VAR Economic_Health Risk Population;&lt;BR /&gt;
FORMAT Region Region.;&lt;BR /&gt;
FORMAT Risk Risk.;&lt;BR /&gt;
FORMAT Economic_Health Economic_Health.;&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
or &lt;BR /&gt;
%macro loopprt;&lt;BR /&gt;
%do Region=1 %to 6 ;&lt;BR /&gt;
&lt;BR /&gt;
PROC PRINT data=PROJET.CORAIL noobs;&lt;BR /&gt;
where region = &amp;amp;region;&lt;BR /&gt;
VAR Economic_Health Risk Population;&lt;BR /&gt;
FORMAT Region Region.;&lt;BR /&gt;
FORMAT Risk Risk.;&lt;BR /&gt;
FORMAT Economic_Health Economic_Health.;&lt;BR /&gt;
&lt;BR /&gt;
RUN;&lt;BR /&gt;
%END;&lt;BR /&gt;
%loopprt;</description>
      <pubDate>Thu, 10 Dec 2009 14:34:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Looping-a-PROC-PRINT/m-p/28378#M6587</guid>
      <dc:creator>Flip</dc:creator>
      <dc:date>2009-12-10T14:34:27Z</dc:date>
    </item>
    <item>
      <title>Re: Looping a PROC PRINT</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Looping-a-PROC-PRINT/m-p/28379#M6588</link>
      <description>Thank-you, the 1st method mentioned with the BY statement works well.</description>
      <pubDate>Thu, 10 Dec 2009 15:27:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Looping-a-PROC-PRINT/m-p/28379#M6588</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-12-10T15:27:35Z</dc:date>
    </item>
  </channel>
</rss>

