<?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: loops using SAS EG in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/loops-using-SAS-EG/m-p/536827#M6669</link>
    <description>&lt;P&gt;Thanks for the info.&lt;/P&gt;</description>
    <pubDate>Tue, 19 Feb 2019 17:13:45 GMT</pubDate>
    <dc:creator>yong_liu</dc:creator>
    <dc:date>2019-02-19T17:13:45Z</dc:date>
    <item>
      <title>loops using SAS EG</title>
      <link>https://communities.sas.com/t5/New-SAS-User/loops-using-SAS-EG/m-p/536088#M6578</link>
      <description>&lt;P&gt;I have several separate SAS codes inside a process flow. Now I want to add loops (by year and lookback) on top of the SAS codes starting from ”2-extract input files” (see the figure attached) to the end. Of course I can put all the codes together and add a Macro like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%MACRO&lt;/STRONG&gt; mFilter(nYr_, lookback_);&lt;/P&gt;&lt;P&gt;Read in macro variables and put all needed codes here&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%MEND&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;* run multiple years;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%MACRO&lt;/STRONG&gt; mMain(nYr1_, nYr2_, lookback_);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %DO y = &amp;amp;nYr1_ %TO &amp;amp;nYr2_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %DO x = 1 %TO &amp;amp;lookback_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %&lt;STRONG&gt;&lt;EM&gt;mFilter&lt;/EM&gt;&lt;/STRONG&gt;(&amp;amp;y, &amp;amp;x)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %END;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%MEND&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %&lt;STRONG&gt;&lt;EM&gt;mMain&lt;/EM&gt;&lt;/STRONG&gt;(&amp;amp;mYear1, &amp;amp;mYear2, &amp;amp;mLookback); * values given;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My question is: Can SAS EG do the loops easily by adding prompts or other ways to the programs or to the process flow while keeping the SAS code programs separate so that it is easy to check logs, and if yes, can you provide details ?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.JPG" style="width: 445px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/27211i8E39E3F89617F6DE/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.JPG" alt="Capture.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Feb 2019 22:59:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/loops-using-SAS-EG/m-p/536088#M6578</guid>
      <dc:creator>yong_liu</dc:creator>
      <dc:date>2019-02-15T22:59:19Z</dc:date>
    </item>
    <item>
      <title>Re: loops using SAS EG</title>
      <link>https://communities.sas.com/t5/New-SAS-User/loops-using-SAS-EG/m-p/536103#M6580</link>
      <description>&lt;P&gt;Assuming you organize your individual programs within a project as a flow (linked programs) which all execute on the same server and same session:&lt;/P&gt;
&lt;P&gt;You could add two additional code nodes and link them into your flow - A) where your loop macro needs to begin, B) where your loop macro needs to end.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Node A) would have code like:&lt;/P&gt;
&lt;PRE&gt;%macro Loop(stop=);
  %do i=1 %to &amp;amp;stop;
  .....
&lt;/PRE&gt;
&lt;P&gt;Node B) would have matching code like:&lt;/P&gt;
&lt;PRE&gt;   ...
   %end;
%mend;

%Loop(stop=&amp;amp;Param_From_Prompt);&lt;/PRE&gt;
&lt;P&gt;... and then define the Prompt with name (here in the example) Param_From_Prompt.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Feb 2019 01:03:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/loops-using-SAS-EG/m-p/536103#M6580</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-02-16T01:03:43Z</dc:date>
    </item>
    <item>
      <title>Re: loops using SAS EG</title>
      <link>https://communities.sas.com/t5/New-SAS-User/loops-using-SAS-EG/m-p/536181#M6591</link>
      <description>You probably can, but in general, SAS offers methods for 'group by' analysis within most proc and data steps so it's usually easier to use that approach overall instead of macro loops. It's definitely more efficient. You can find a paper called Don't Be Loopy, by David Cassell that outlines why this is a better approach.</description>
      <pubDate>Sat, 16 Feb 2019 18:23:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/loops-using-SAS-EG/m-p/536181#M6591</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-02-16T18:23:35Z</dc:date>
    </item>
    <item>
      <title>Re: loops using SAS EG</title>
      <link>https://communities.sas.com/t5/New-SAS-User/loops-using-SAS-EG/m-p/536826#M6668</link>
      <description>&lt;P&gt;Thanks for the response. I will give a try&lt;/P&gt;</description>
      <pubDate>Tue, 19 Feb 2019 17:12:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/loops-using-SAS-EG/m-p/536826#M6668</guid>
      <dc:creator>yong_liu</dc:creator>
      <dc:date>2019-02-19T17:12:44Z</dc:date>
    </item>
    <item>
      <title>Re: loops using SAS EG</title>
      <link>https://communities.sas.com/t5/New-SAS-User/loops-using-SAS-EG/m-p/536827#M6669</link>
      <description>&lt;P&gt;Thanks for the info.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Feb 2019 17:13:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/loops-using-SAS-EG/m-p/536827#M6669</guid>
      <dc:creator>yong_liu</dc:creator>
      <dc:date>2019-02-19T17:13:45Z</dc:date>
    </item>
  </channel>
</rss>

