<?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 Do loop for where &amp;quot;i&amp;quot; equals specific values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-for-where-quot-i-quot-equals-specific-values/m-p/116581#M24045</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dataset FILES_TO_PROCESS looks like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="text-decoration: underline; font-family: courier new,courier;"&gt;FILE_NUM&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;401&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;412&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;439&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P&gt;I'd like to create a macro program with a do loop where "i" takes on those values. My workaround is something like this...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;proc sql;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select min(FILE_NUM) into :min_num&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from FILES_TO_PROCESS&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select max(FILE_NUM) into :max_num&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from FILES_TO_PROCESS&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;%macro start_processing; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %do i = &amp;amp;min_num %to &amp;amp;max_num;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;yadda yadda yadda&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;%mend;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But of course that will cause the do loop to iterate 39 times, as opposed to just the 3 needed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Help! &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 02 Nov 2012 21:20:23 GMT</pubDate>
    <dc:creator>jawon</dc:creator>
    <dc:date>2012-11-02T21:20:23Z</dc:date>
    <item>
      <title>Do loop for where "i" equals specific values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-for-where-quot-i-quot-equals-specific-values/m-p/116581#M24045</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dataset FILES_TO_PROCESS looks like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="text-decoration: underline; font-family: courier new,courier;"&gt;FILE_NUM&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;401&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;412&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;439&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P&gt;I'd like to create a macro program with a do loop where "i" takes on those values. My workaround is something like this...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;proc sql;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select min(FILE_NUM) into :min_num&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from FILES_TO_PROCESS&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select max(FILE_NUM) into :max_num&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from FILES_TO_PROCESS&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;%macro start_processing; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %do i = &amp;amp;min_num %to &amp;amp;max_num;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;yadda yadda yadda&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;%mend;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But of course that will cause the do loop to iterate 39 times, as opposed to just the 3 needed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Help! &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Nov 2012 21:20:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop-for-where-quot-i-quot-equals-specific-values/m-p/116581#M24045</guid>
      <dc:creator>jawon</dc:creator>
      <dc:date>2012-11-02T21:20:23Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop for where "i" equals specific values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-for-where-quot-i-quot-equals-specific-values/m-p/116582#M24046</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Where is the files to process coming from, a SAS library or a windows or unix directory.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If they all have the same extension you can use a wildcard to process everything in one directory at once...depending on what you're doing of course. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Nov 2012 21:25:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop-for-where-quot-i-quot-equals-specific-values/m-p/116582#M24046</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2012-11-02T21:25:04Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop for where "i" equals specific values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-for-where-quot-i-quot-equals-specific-values/m-p/116583#M24047</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here's a quick example of taking one field from multiple rows of data file and stepping through them. Look in the log for the output.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;%macro dummy; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql noprint; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select make into :cars separated by ' ' &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;from sasuser.carpref &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;quit; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%do i = 1 %to &amp;amp;sqlobs ; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let name= %scan(&amp;amp;cars,&amp;amp;i); &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%put Do something with &amp;amp;name; /* this is where your useful code would go*/&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;&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;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%dummy;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Nov 2012 21:56:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop-for-where-quot-i-quot-equals-specific-values/m-p/116583#M24047</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2012-11-02T21:56:16Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop for where "i" equals specific values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-for-where-quot-i-quot-equals-specific-values/m-p/116584#M24048</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would suggest that you provide an example of what you really want to accomplish.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Nov 2012 22:05:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop-for-where-quot-i-quot-equals-specific-values/m-p/116584#M24048</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-11-02T22:05:45Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop for where "i" equals specific values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-for-where-quot-i-quot-equals-specific-values/m-p/116585#M24049</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you ballardw, that works like a charm! Apologies to the others for not providing the full details, but I guess I got lucky that ballardw was on the same wavelength &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Nov 2012 22:40:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop-for-where-quot-i-quot-equals-specific-values/m-p/116585#M24049</guid>
      <dc:creator>jawon</dc:creator>
      <dc:date>2012-11-02T22:40:59Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop for where "i" equals specific values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-for-where-quot-i-quot-equals-specific-values/m-p/116586#M24050</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Glad to hear that you received an answer that you found useful.&amp;nbsp; However, in the future, the more details you can provide upfront, the more quickly and assuredly others can try to provide a useful response.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Nov 2012 22:45:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop-for-where-quot-i-quot-equals-specific-values/m-p/116586#M24050</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-11-02T22:45:01Z</dc:date>
    </item>
  </channel>
</rss>

