<?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: Do Loop to pass value to body of code in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Do-Loop-to-pass-value-to-body-of-code/m-p/191495#M266135</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm not sure quite what you are attempting to actually accomplish. Are you trying to use the loop to call the two steps with data pfm within the loop?&lt;/P&gt;&lt;P&gt;If you post some example data, as data step code preferably, and what the desired output should be that would help.&lt;/P&gt;&lt;P&gt;Also for test purposes I would think very carefully about using the:&lt;/P&gt;&lt;P&gt;Data pfm; set pfm;&lt;/P&gt;&lt;P&gt;structure. Reusing the same data set before you have the results you need leads to difficulty determining where a re-assignment error occurs.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 01 Dec 2014 17:01:26 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2014-12-01T17:01:26Z</dc:date>
    <item>
      <title>Do Loop to pass value to body of code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-Loop-to-pass-value-to-body-of-code/m-p/191494#M266134</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Everyone,&lt;/P&gt;&lt;P&gt;I want to run my code for different values of variable lookback using this rule&lt;BR /&gt;Do lookback=4 to 10 by 2;&lt;/P&gt;&lt;P&gt;I know that I can make a macro say %macro mymacro(lookback=) and then list the value.&lt;/P&gt;&lt;P&gt;This code is for demonstration purpose only.&lt;/P&gt;&lt;P&gt;I really want to make a DO to pass the value into the body of the code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you please help me with that?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HHC&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do lookback=4 to 10 by 2;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data pfm; set pfm;&lt;BR /&gt;drop i j l1 h1; &lt;BR /&gt;lowest=1000;&lt;BR /&gt;highest=0;&lt;BR /&gt;i+1;&lt;BR /&gt; do j=i to i+ lookback;&lt;BR /&gt; set pfm (keep=low high rename =(low=l1 high=h1)) point=j;&lt;BR /&gt; if lowest&amp;gt;l1&amp;nbsp; then lowest=l1;&lt;BR /&gt; if highest&amp;lt;h1&amp;nbsp; then highest=h1; &lt;BR /&gt; end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data pfm; set pfm;&lt;BR /&gt;rename&lt;BR /&gt;lowest=lowest_&lt;SPAN style="text-decoration: underline;"&gt;lookback&amp;nbsp; *How can I turn it into number lookback?;&lt;/SPAN&gt;&lt;BR /&gt;highest=highest_lookback;&lt;BR /&gt;run;&lt;BR /&gt;....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Dec 2014 04:06:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-Loop-to-pass-value-to-body-of-code/m-p/191494#M266134</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2014-12-01T04:06:31Z</dc:date>
    </item>
    <item>
      <title>Re: Do Loop to pass value to body of code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-Loop-to-pass-value-to-body-of-code/m-p/191495#M266135</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm not sure quite what you are attempting to actually accomplish. Are you trying to use the loop to call the two steps with data pfm within the loop?&lt;/P&gt;&lt;P&gt;If you post some example data, as data step code preferably, and what the desired output should be that would help.&lt;/P&gt;&lt;P&gt;Also for test purposes I would think very carefully about using the:&lt;/P&gt;&lt;P&gt;Data pfm; set pfm;&lt;/P&gt;&lt;P&gt;structure. Reusing the same data set before you have the results you need leads to difficulty determining where a re-assignment error occurs.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Dec 2014 17:01:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-Loop-to-pass-value-to-body-of-code/m-p/191495#M266135</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-12-01T17:01:26Z</dc:date>
    </item>
    <item>
      <title>Re: Do Loop to pass value to body of code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-Loop-to-pass-value-to-body-of-code/m-p/191496#M266136</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;%macro test;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%do oldvar=2 %to 6 %by 2;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test&amp;amp;oldvar;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;set sashelp.class;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%test;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;For discrete value&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%let oldvar=4 5 20;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro test;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%do i=1 %to %sysfunc(countw(&amp;amp;oldvar));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let newvar=%scan(&amp;amp;oldvar,&amp;amp;i);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test&amp;amp;newvar;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;set sashelp.class;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%test;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Harry Ng&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Dec 2014 17:19:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-Loop-to-pass-value-to-body-of-code/m-p/191496#M266136</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2014-12-01T17:19:52Z</dc:date>
    </item>
  </channel>
</rss>

