<?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 Need help with creating a do loop in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-creating-a-do-loop/m-p/36880#M7262</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks a lot! This works. This is very similar to how I did it originally. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The only change needed is probably in the %scan function. Right now it is only using the C from CA (and N from NY etc) fwhen resolving &lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;%let value=%scan(&amp;amp;values,&amp;amp;i);&lt;/SPAN&gt;,&lt;/P&gt;&lt;P&gt; while it needs to use the whole CA.I can probably take care of that.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 19 Mar 2012 21:39:22 GMT</pubDate>
    <dc:creator>amitsas</dc:creator>
    <dc:date>2012-03-19T21:39:22Z</dc:date>
    <item>
      <title>Need help with creating a do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-creating-a-do-loop/m-p/36876#M7258</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am hoping someone can help with request.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to create (say) 5 tables or data sets, for 5 states - CA, VA, NY, TX and OK&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Each table has some information based on some criteria (say, name of state and its population). So the table for California looks like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CA&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 34,000,000&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can have a data step to do this, but I want to put the names of states in a marco variable string along with a do loop so that the do loop runs and creates a data step for each state in the macro variable string,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for example&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%LET STATE = CA VA NY TX OK;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;do loop (CA)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;followed by&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;do loop VA etc..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks to all who try to help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Mar 2012 20:26:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-creating-a-do-loop/m-p/36876#M7258</guid>
      <dc:creator>amitsas</dc:creator>
      <dc:date>2012-03-19T20:26:02Z</dc:date>
    </item>
    <item>
      <title>Need help with creating a do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-creating-a-do-loop/m-p/36877#M7259</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Is this a homework? What have you tried so far?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Mar 2012 20:31:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-creating-a-do-loop/m-p/36877#M7259</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2012-03-19T20:31:30Z</dc:date>
    </item>
    <item>
      <title>Need help with creating a do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-creating-a-do-loop/m-p/36878#M7260</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is not a homework.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I haven't used SAS in a while. I have a list of close to 2000 values for which I have retrieve some data. And I do not want to run the code 2000 times, based on each value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From what i remember when I did do it, I used a long character string as a macro variable, and resolved the value by moving the do loop counter by 1 and then ran the code. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Mar 2012 20:36:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-creating-a-do-loop/m-p/36878#M7260</guid>
      <dc:creator>amitsas</dc:creator>
      <dc:date>2012-03-19T20:36:26Z</dc:date>
    </item>
    <item>
      <title>Need help with creating a do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-creating-a-do-loop/m-p/36879#M7261</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; What you want would like this, I guess :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;options mprint;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%LET STATES = CA VA NY TX OK;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro doloop(values);&lt;BR /&gt; %let i = 1;&lt;BR /&gt; %do %while(%length(%scan(&amp;amp;values,&amp;amp;i)) &amp;gt; 0);&lt;BR /&gt;&amp;nbsp; %let value=%scan(&amp;amp;values,&amp;amp;i);&lt;BR /&gt;&amp;nbsp; data _&amp;amp;value.;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; t = "&amp;amp;value";&lt;BR /&gt;&amp;nbsp; run; &lt;BR /&gt;&amp;nbsp; %let i = %eval(&amp;amp;i+1);&lt;BR /&gt; %end;&lt;BR /&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%doLoop(&amp;amp;STATES);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Mar 2012 20:55:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-creating-a-do-loop/m-p/36879#M7261</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2012-03-19T20:55:50Z</dc:date>
    </item>
    <item>
      <title>Need help with creating a do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-creating-a-do-loop/m-p/36880#M7262</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks a lot! This works. This is very similar to how I did it originally. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The only change needed is probably in the %scan function. Right now it is only using the C from CA (and N from NY etc) fwhen resolving &lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;%let value=%scan(&amp;amp;values,&amp;amp;i);&lt;/SPAN&gt;,&lt;/P&gt;&lt;P&gt; while it needs to use the whole CA.I can probably take care of that.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Mar 2012 21:39:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-creating-a-do-loop/m-p/36880#M7262</guid>
      <dc:creator>amitsas</dc:creator>
      <dc:date>2012-03-19T21:39:22Z</dc:date>
    </item>
    <item>
      <title>Need help with creating a do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-creating-a-do-loop/m-p/36881#M7263</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; %SCAN is supposed to extract a word, not just a letter. In my tests, 5 datasets were created : _CA, _VA, _NY, _TX, and _OK. Can you post your macro?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Mar 2012 21:46:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-creating-a-do-loop/m-p/36881#M7263</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2012-03-19T21:46:58Z</dc:date>
    </item>
    <item>
      <title>Need help with creating a do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-creating-a-do-loop/m-p/36882#M7264</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I just ran your macro without making any changes. But if you open the dataset, the value inside is C and not CA&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Mar 2012 21:48:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-creating-a-do-loop/m-p/36882#M7264</guid>
      <dc:creator>amitsas</dc:creator>
      <dc:date>2012-03-19T21:48:31Z</dc:date>
    </item>
    <item>
      <title>Need help with creating a do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-creating-a-do-loop/m-p/36883#M7265</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; It just looks that way in FSVIEW. Expand the column width and you will see that the whole value (2-letter) is there.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Mar 2012 21:52:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-creating-a-do-loop/m-p/36883#M7265</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2012-03-19T21:52:20Z</dc:date>
    </item>
    <item>
      <title>Need help with creating a do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-creating-a-do-loop/m-p/36884#M7266</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry for my ignorance, and thank you again!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Mar 2012 21:54:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-creating-a-do-loop/m-p/36884#M7266</guid>
      <dc:creator>amitsas</dc:creator>
      <dc:date>2012-03-19T21:54:20Z</dc:date>
    </item>
    <item>
      <title>Need help with creating a do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-creating-a-do-loop/m-p/36885#M7267</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You're welcome. Cheers!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Mar 2012 21:59:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-creating-a-do-loop/m-p/36885#M7267</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2012-03-19T21:59:07Z</dc:date>
    </item>
  </channel>
</rss>

