<?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: create a list of macro variable to loop thru in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/create-a-list-of-macro-variable-to-loop-thru/m-p/317073#M69363</link>
    <description>&lt;P&gt;That's a common enough question .... here's a link:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.sas.com/content/sastraining/2015/01/30/sas-authors-tip-getting-the-macro-language-to-perform-a-do-loop-over-a-list-of-values/" target="_blank"&gt;http://blogs.sas.com/content/sastraining/2015/01/30/sas-authors-tip-getting-the-macro-language-to-perform-a-do-loop-over-a-list-of-values/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 06 Dec 2016 17:18:18 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2016-12-06T17:18:18Z</dc:date>
    <item>
      <title>create a list of macro variable to loop thru</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-a-list-of-macro-variable-to-loop-thru/m-p/317070#M69362</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a data sets that I'd like to to a proc with and I want to loop through the columns&lt;/P&gt;
&lt;P&gt;looks like this&lt;/P&gt;
&lt;TABLE width="320"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="64"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="64"&gt;apple&amp;nbsp;&lt;/TD&gt;
&lt;TD width="64"&gt;orange&lt;/TD&gt;
&lt;TD width="64"&gt;seeds&lt;/TD&gt;
&lt;TD width="64"&gt;red&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;obs1&lt;/TD&gt;
&lt;TD&gt;12&lt;/TD&gt;
&lt;TD&gt;12&lt;/TD&gt;
&lt;TD&gt;12&lt;/TD&gt;
&lt;TD&gt;12&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;obs2&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;obs3&lt;/TD&gt;
&lt;TD&gt;-8&lt;/TD&gt;
&lt;TD&gt;-8&lt;/TD&gt;
&lt;TD&gt;-8&lt;/TD&gt;
&lt;TD&gt;-8&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;what I wanted to do is this&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%do i=1 to end;&lt;/P&gt;
&lt;P&gt;proc glm;&lt;/P&gt;
&lt;P&gt;model y=&amp;amp;varlist&amp;amp;i;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;%end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;so I can run the proc against each of the variable in my variable list.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can easily create the &amp;amp;varlist. using proc sql, but I wanted to run the proc glm on each of the vaeriable list (not all of them)&lt;/P&gt;
&lt;P&gt;can anyone show me how to&amp;nbsp;create this &amp;amp;varlist&amp;amp;i?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;use symput?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;More explicitly,&lt;/P&gt;
&lt;P&gt;%let names=Susan Mary Alice Zeta Queen......Evin;&lt;/P&gt;
&lt;P&gt;I wanted to have sometime embeded with it, say &amp;amp;i.&lt;/P&gt;
&lt;P&gt;so I can have names get recognized as &amp;amp;&amp;amp;list.&amp;amp;i, e.g. &amp;amp;names1.=susan &lt;SPAN&gt;&amp;amp;names2.=Mary,&amp;nbsp;&amp;amp;names3.=zeta,&amp;nbsp;&amp;amp;names4.=Queen and so on.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;a extended quesiton will be, is there any doc that I can find such tutorial or logic to build such mechanism for broder &amp;amp;&amp;amp;&amp;amp;type of marco use?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thank you!!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2016 16:18:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-a-list-of-macro-variable-to-loop-thru/m-p/317070#M69362</guid>
      <dc:creator>Lulus</dc:creator>
      <dc:date>2016-12-07T16:18:18Z</dc:date>
    </item>
    <item>
      <title>Re: create a list of macro variable to loop thru</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-a-list-of-macro-variable-to-loop-thru/m-p/317073#M69363</link>
      <description>&lt;P&gt;That's a common enough question .... here's a link:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.sas.com/content/sastraining/2015/01/30/sas-authors-tip-getting-the-macro-language-to-perform-a-do-loop-over-a-list-of-values/" target="_blank"&gt;http://blogs.sas.com/content/sastraining/2015/01/30/sas-authors-tip-getting-the-macro-language-to-perform-a-do-loop-over-a-list-of-values/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Dec 2016 17:18:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-a-list-of-macro-variable-to-loop-thru/m-p/317073#M69363</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-12-06T17:18:18Z</dc:date>
    </item>
    <item>
      <title>Re: create a list of macro variable to loop thru</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-a-list-of-macro-variable-to-loop-thru/m-p/317153#M69394</link>
      <description>&lt;P&gt;See the example on this page, under:&lt;/P&gt;
&lt;H4&gt;A macro program for repeating a procedure multiple times&lt;/H4&gt;
&lt;P&gt;&lt;A href="http://www.ats.ucla.edu/stat/sas/seminars/sas_macros_introduction/" target="_blank"&gt;http://www.ats.ucla.edu/stat/sas/seminars/sas_macros_introduction/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Dec 2016 21:51:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-a-list-of-macro-variable-to-loop-thru/m-p/317153#M69394</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-12-06T21:51:59Z</dc:date>
    </item>
    <item>
      <title>Re: create a list of macro variable to loop thru</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-a-list-of-macro-variable-to-loop-thru/m-p/317349#M69473</link>
      <description>&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2016 16:01:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-a-list-of-macro-variable-to-loop-thru/m-p/317349#M69473</guid>
      <dc:creator>Lulus</dc:creator>
      <dc:date>2016-12-07T16:01:34Z</dc:date>
    </item>
    <item>
      <title>Re: create a list of macro variable to loop thru</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-a-list-of-macro-variable-to-loop-thru/m-p/317359#M69475</link>
      <description>&lt;P&gt;Thank you, I actually saw this solution before I posted my question.&lt;/P&gt;
&lt;P&gt;This works but I was looking more for that how to create indexes for my macro variable contains multiple variables names in there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;for example,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let names=Susan Mary Alice Zeta Queen......Evin;&lt;/P&gt;
&lt;P&gt;I wanted to have sometime embeded with it, say &amp;amp;i.&lt;/P&gt;
&lt;P&gt;so I can have names get recognized as &amp;amp;&amp;amp;list.&amp;amp;i, e.g. &amp;amp;names1.=susan &lt;SPAN&gt;&amp;amp;names2.=Mary,&amp;nbsp;&amp;amp;names3.=zeta,&amp;nbsp;&amp;amp;names4.=Queen and so on.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;a extended quesiton will be, is there any doc that I can find such tutorial or logic to build such mechanism for broder &amp;amp;&amp;amp;&amp;amp;type of marco use?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thank you!!&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2016 16:17:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-a-list-of-macro-variable-to-loop-thru/m-p/317359#M69475</guid>
      <dc:creator>Lulus</dc:creator>
      <dc:date>2016-12-07T16:17:01Z</dc:date>
    </item>
    <item>
      <title>Re: create a list of macro variable to loop thru</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-a-list-of-macro-variable-to-loop-thru/m-p/317370#M69480</link>
      <description>&lt;P&gt;Can you show exactly what code the macro is supposed to generate for a given macro variable containing a list?&lt;/P&gt;
&lt;P&gt;How you are actually using things helps provide better responses.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2016 16:32:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-a-list-of-macro-variable-to-loop-thru/m-p/317370#M69480</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-12-07T16:32:32Z</dc:date>
    </item>
    <item>
      <title>Re: create a list of macro variable to loop thru</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-a-list-of-macro-variable-to-loop-thru/m-p/317375#M69482</link>
      <description>&lt;P&gt;Let's suppose this is your starting point:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let names=Susan Mary Alice Zeta Queen......Evin;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Inside a macro, you can add code like this to split &amp;amp;NAMES into separate variables:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%do i=1 %to %sysfunc(countw(&amp;amp;names));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; %let name&amp;amp;i = %scan(&amp;amp;names, &amp;amp;i, %str( ));&lt;/P&gt;
&lt;P&gt;%end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;While this can be done, it also can add unnecessary complexity to the subsequent processing.&amp;nbsp; So it's a choice you need to make.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2016 16:43:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-a-list-of-macro-variable-to-loop-thru/m-p/317375#M69482</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-12-07T16:43:26Z</dc:date>
    </item>
    <item>
      <title>Re: create a list of macro variable to loop thru</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-a-list-of-macro-variable-to-loop-thru/m-p/317419#M69498</link>
      <description>&lt;P&gt;Thank you for getting back to me. &amp;nbsp;I just had it answered below.&lt;/P&gt;
&lt;P&gt;I appreciate your help and hope to learn again from you next time!&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2016 19:10:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-a-list-of-macro-variable-to-loop-thru/m-p/317419#M69498</guid>
      <dc:creator>Lulus</dc:creator>
      <dc:date>2016-12-07T19:10:22Z</dc:date>
    </item>
  </channel>
</rss>

