<?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: IF statement with a macro - how to create a loop in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/IF-statement-with-a-macro-how-to-create-a-loop/m-p/107217#M258629</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;STRONG style="font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;A _jive_internal="true" class="jiveTT-hover-user jive-username-link" data-avatarid="-1" data-externalid="" data-presence="null" data-userid="5253" data-username="Astounding" href="https://communities.sas.com/people/Astounding" id="jive-525342965403012703803" style="padding: 0 3px 0 0; font-weight: inherit; font-style: inherit; font-size: 1.1em; font-family: inherit; color: #0e66ba;"&gt;Astounding,&lt;/A&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;my concatenate function is not working (As hilighted below)... if I can get only that working I think my problem will be solved... &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA TABLE1;&lt;/P&gt;&lt;P&gt; SET TABLE1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NEXT_DAY = 1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do date=today()to date=today()+14;&lt;/P&gt;&lt;P&gt; A_DATE&amp;nbsp; &amp;lt; = dhms(date+1,7,0,0)&amp;nbsp; and&lt;/P&gt;&lt;P&gt; A_DATE_END&amp;nbsp; &amp;lt; = dhms(date+1,7,0,0)&amp;nbsp; and&lt;/P&gt;&lt;P&gt; B_DATE&amp;nbsp; &amp;gt; dhms(date+1,7,0,0) and&lt;/P&gt;&lt;P&gt; B_DATE_END&amp;nbsp; &amp;gt;&amp;nbsp; dhms(date+1,7,0,0)&lt;/P&gt;&lt;P&gt;THEN&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'D'||Next_DAY||'_VOL'&lt;/STRONG&gt; = VOL1;&lt;/P&gt;&lt;P&gt;ELSE &lt;STRONG&gt; 'D'||Next_DAY||'_VOL' &lt;/STRONG&gt; = 0;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;NEXT_DAY = NEXT_DAY+ +1;&lt;/P&gt;&lt;P&gt;End;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 16 Jul 2012 22:41:13 GMT</pubDate>
    <dc:creator>tparvaiz</dc:creator>
    <dc:date>2012-07-16T22:41:13Z</dc:date>
    <item>
      <title>IF statement with a macro - how to create a loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-statement-with-a-macro-how-to-create-a-loop/m-p/107215#M258627</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have 10 if statements that uses a macro... is there a way to use a loop so that I don't have to type them 10 times&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A_DATE&amp;nbsp; &amp;lt; = "&amp;amp;NEXT_DAY_1"dt+'07:00:00't&amp;nbsp; and&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A_DATE_END&amp;nbsp; &amp;lt; = "&amp;amp;NEXT_DAY_1"dt+'07:00:00't and&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; B_DATE&amp;nbsp; &amp;gt;&amp;nbsp; "&amp;amp;NEXT_DAY_1"dt+'07:00:00't and&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; B_DATE_END&amp;nbsp; &amp;gt;&amp;nbsp; "&amp;amp;NEXT_DAY_1"dt+'07:00:00't&lt;/P&gt;&lt;P&gt;THEN&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; D2_VOL = VOL1;&lt;/P&gt;&lt;P&gt;ELSE D2_VOL = 0;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A_DATE&amp;nbsp; &amp;lt; = "&amp;amp;NEXT_DAY_2"dt+'07:00:00't&amp;nbsp; and&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A_DATE_END&amp;nbsp; &amp;lt; = "&amp;amp;NEXT_DAY_2"dt+'07:00:00't and&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; B_DATE&amp;nbsp; &amp;gt;&amp;nbsp; "&amp;amp;NEXT_DAY_2"dt+'07:00:00't and&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; B_DATE_END&amp;nbsp; &amp;gt;&amp;nbsp; "&amp;amp;NEXT_DAY_2"dt+'07:00:00't&lt;/P&gt;&lt;P&gt;THEN&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; D2_VOL = VOL1;&lt;/P&gt;&lt;P&gt;ELSE D2_VOL = 0;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A_DATE&amp;nbsp; &amp;lt; = "&amp;amp;NEXT_DAY_3"dt+'07:00:00't&amp;nbsp; and&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A_DATE_END&amp;nbsp; &amp;lt; = "&amp;amp;NEXT_DAY_3"dt+'07:00:00't and&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; B_DATE&amp;nbsp; &amp;gt;&amp;nbsp; "&amp;amp;NEXT_DAY_3"dt+'07:00:00't and&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; B_DATE_END&amp;nbsp; &amp;gt;&amp;nbsp; "&amp;amp;NEXT_DAY_3"dt+'07:00:00't&lt;/P&gt;&lt;P&gt;THEN&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; D3_VOL = VOL1;&lt;/P&gt;&lt;P&gt;ELSE D3_VOL = 0;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and so on&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am looking for something like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;do for X = 1 to 10&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A_DATE&amp;nbsp; &amp;lt; = "&amp;amp;NEXT_DAY_&lt;STRONG&gt;X&lt;/STRONG&gt;"dt+'07:00:00't&amp;nbsp; and&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A_DATE_END&amp;nbsp; &amp;lt; = "&amp;amp;NEXT_DAY_&lt;STRONG&gt;X&lt;/STRONG&gt;"dt+'07:00:00't and&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; B_DATE&amp;nbsp; &amp;gt;&amp;nbsp; "&amp;amp;NEXT_DAY_&lt;STRONG&gt;X&lt;/STRONG&gt;"dt+'07:00:00't and&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; B_DATE_END&amp;nbsp; &amp;gt;&amp;nbsp; "&amp;amp;NEXT_DAY_&lt;STRONG&gt;X&lt;/STRONG&gt;"dt+'07:00:00't&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; THEN&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; D&lt;STRONG&gt;X&lt;/STRONG&gt;_VOL = VOL1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ELSE &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; D&lt;STRONG&gt;X&lt;/STRONG&gt;_VOL = 0;&lt;/P&gt;&lt;P&gt;Loop&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please advice&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 14 Jul 2012 04:56:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-statement-with-a-macro-how-to-create-a-loop/m-p/107215#M258627</guid>
      <dc:creator>tparvaiz</dc:creator>
      <dc:date>2012-07-14T04:56:05Z</dc:date>
    </item>
    <item>
      <title>Re: IF statement with a macro - how to create a loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-statement-with-a-macro-how-to-create-a-loop/m-p/107216#M258628</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;tparvaiz,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The right tool for the job is arrays.&amp;nbsp; Here is an example that uses the macro variables you have already created.&amp;nbsp; All of this belongs in the DATA step:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;array times {10} "&amp;amp;next_day_1"dt "&amp;amp;next_day_2"dt "&amp;amp;next_day_3"dt ... "&amp;amp;next_day_10"dt;&lt;/P&gt;&lt;P&gt;array vols {10} d1_vol d2_vol d3_vol ... d10_vol;&lt;/P&gt;&lt;P&gt;do _i_=1 to 10;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; vols{_i_}=0;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if A_DATE &amp;lt; times{_i_} + '07:00:00't&amp;nbsp; and A_DATE_END &amp;lt;= times{_i_} + '07:00:00't&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; and B_DATE &amp;gt; times{_i_} + '07:00:00't and B_DATE_END &amp;gt; times{_i_} + '07:00:00't&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; then vols{_i_} = VOL1;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You'll have to type out all 10 elements in each array.&amp;nbsp; But this is the right direction, I'm pretty sure.&amp;nbsp; See if it works for you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Jul 2012 21:14:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-statement-with-a-macro-how-to-create-a-loop/m-p/107216#M258628</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-07-16T21:14:38Z</dc:date>
    </item>
    <item>
      <title>Re: IF statement with a macro - how to create a loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-statement-with-a-macro-how-to-create-a-loop/m-p/107217#M258629</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;STRONG style="font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;A _jive_internal="true" class="jiveTT-hover-user jive-username-link" data-avatarid="-1" data-externalid="" data-presence="null" data-userid="5253" data-username="Astounding" href="https://communities.sas.com/people/Astounding" id="jive-525342965403012703803" style="padding: 0 3px 0 0; font-weight: inherit; font-style: inherit; font-size: 1.1em; font-family: inherit; color: #0e66ba;"&gt;Astounding,&lt;/A&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;my concatenate function is not working (As hilighted below)... if I can get only that working I think my problem will be solved... &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA TABLE1;&lt;/P&gt;&lt;P&gt; SET TABLE1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NEXT_DAY = 1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do date=today()to date=today()+14;&lt;/P&gt;&lt;P&gt; A_DATE&amp;nbsp; &amp;lt; = dhms(date+1,7,0,0)&amp;nbsp; and&lt;/P&gt;&lt;P&gt; A_DATE_END&amp;nbsp; &amp;lt; = dhms(date+1,7,0,0)&amp;nbsp; and&lt;/P&gt;&lt;P&gt; B_DATE&amp;nbsp; &amp;gt; dhms(date+1,7,0,0) and&lt;/P&gt;&lt;P&gt; B_DATE_END&amp;nbsp; &amp;gt;&amp;nbsp; dhms(date+1,7,0,0)&lt;/P&gt;&lt;P&gt;THEN&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'D'||Next_DAY||'_VOL'&lt;/STRONG&gt; = VOL1;&lt;/P&gt;&lt;P&gt;ELSE &lt;STRONG&gt; 'D'||Next_DAY||'_VOL' &lt;/STRONG&gt; = 0;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;NEXT_DAY = NEXT_DAY+ +1;&lt;/P&gt;&lt;P&gt;End;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Jul 2012 22:41:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-statement-with-a-macro-how-to-create-a-loop/m-p/107217#M258629</guid>
      <dc:creator>tparvaiz</dc:creator>
      <dc:date>2012-07-16T22:41:13Z</dc:date>
    </item>
    <item>
      <title>Re: IF statement with a macro - how to create a loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-statement-with-a-macro-how-to-create-a-loop/m-p/107218#M258630</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That is not going to work.&amp;nbsp; You cannot create the name of the variable you want to reference in the code after the program has already been compiled.&lt;/P&gt;&lt;P&gt;Either use Array reference to determine at run time which variable to reference.&lt;/P&gt;&lt;P&gt;Or use an actual macro (not a macro variable) to generate a series of statements.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What is that actual problem that you want to do?&amp;nbsp; &lt;/P&gt;&lt;P&gt;What is the format of your input dataset?&amp;nbsp; What do you want to do with it.&amp;nbsp; How does the proposed structure that you are trying to create help?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Jul 2012 22:47:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-statement-with-a-macro-how-to-create-a-loop/m-p/107218#M258630</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-07-16T22:47:42Z</dc:date>
    </item>
  </channel>
</rss>

