<?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: How to generate sequencial macro variable names and how to list them short in sas in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-sequencial-macro-variable-names-and-how-to-list/m-p/640127#M190587</link>
    <description>&lt;P&gt;Note the IN operator does NOT need commas separating the items in the list. Spaces work just fine.&lt;/P&gt;</description>
    <pubDate>Wed, 15 Apr 2020 15:15:14 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2020-04-15T15:15:14Z</dc:date>
    <item>
      <title>How to generate sequencial macro variable names and how to list them short in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-sequencial-macro-variable-names-and-how-to-list/m-p/640071#M190548</link>
      <description>&lt;P&gt;Dear SAS Community,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;I have macro variables generated from &amp;amp;var1 to &amp;amp;var50. I want to query them in PROC SQL and list them in where clause (like &amp;amp;var1 or &amp;amp;var2 .....or &amp;amp;var50). How can I generate a macro to list all of these 50 variables with 'OR' separation to list.&lt;/P&gt;&lt;P&gt;I want to have a single macro to list all of these 50 variables like (%let new= &amp;amp;var1 or &amp;amp;var2 .... &amp;amp;50).&amp;nbsp;&lt;/P&gt;&lt;P&gt;In data step we have : operator to list (like var: will get all of the variables whose prefix changes).&amp;nbsp;&lt;/P&gt;&lt;P&gt;example code:&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table new_table as&amp;nbsp;&lt;/P&gt;&lt;P&gt;select *&lt;/P&gt;&lt;P&gt;from want&amp;nbsp;&lt;/P&gt;&lt;P&gt;where number in (&amp;amp;new); quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2020 11:19:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-generate-sequencial-macro-variable-names-and-how-to-list/m-p/640071#M190548</guid>
      <dc:creator>buddha_d</dc:creator>
      <dc:date>2020-04-15T11:19:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate sequencial macro variable names and how to list them short in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-sequencial-macro-variable-names-and-how-to-list/m-p/640073#M190550</link>
      <description>&lt;P&gt;What do these macro variables contain? Values or variable names? And in which form? And how many?&lt;/P&gt;
&lt;P&gt;If you get these values from a dataset, it's much better to use a sub-select.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2020 11:31:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-generate-sequencial-macro-variable-names-and-how-to-list/m-p/640073#M190550</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-04-15T11:31:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate sequencial macro variable names and how to list them short in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-sequencial-macro-variable-names-and-how-to-list/m-p/640074#M190551</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro dothis;
proc sql;
    create table new_table as 
    select * from want 
    where number in (%do i=1 %to 50; &amp;amp;&amp;amp;var&amp;amp;i %if &amp;amp;i&amp;lt;50 %then %str(,); %end;); 
quit;
%mend;
%dothis&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Please note: the syntax you are using&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;where number in (&amp;amp;var1 or &amp;amp;var2 or ...) &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;doesn't seem correct as the OR does not belong in the IN () as far as I know. SQL works fine with commas or spaces as the separator, I have programmed it to have a comma as the separator.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And I agree with&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;, you would be better off using some other structure here, if possible, as he suggests.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2020 11:36:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-generate-sequencial-macro-variable-names-and-how-to-list/m-p/640074#M190551</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-04-15T11:36:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate sequencial macro variable names and how to list them short in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-sequencial-macro-variable-names-and-how-to-list/m-p/640116#M190578</link>
      <description>&lt;P&gt;It may help a lot to show an example of the SQL query that &lt;STRONG&gt;works&lt;/STRONG&gt; without any macro coding or variables.&lt;/P&gt;
&lt;P&gt;Then tell us which part of the query you want the macro values used.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2020 14:46:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-generate-sequencial-macro-variable-names-and-how-to-list/m-p/640116#M190578</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-04-15T14:46:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate sequencial macro variable names and how to list them short in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-sequencial-macro-variable-names-and-how-to-list/m-p/640127#M190587</link>
      <description>&lt;P&gt;Note the IN operator does NOT need commas separating the items in the list. Spaces work just fine.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2020 15:15:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-generate-sequencial-macro-variable-names-and-how-to-list/m-p/640127#M190587</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-04-15T15:15:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate sequencial macro variable names and how to list them short in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-sequencial-macro-variable-names-and-how-to-list/m-p/640209#M190622</link>
      <description>I can't list the code of macro variables I am creating, but I needed a way to list them. Since there are so many and I can't really post the original code. Thanks for your response. I appreciate it&lt;BR /&gt;</description>
      <pubDate>Wed, 15 Apr 2020 20:33:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-generate-sequencial-macro-variable-names-and-how-to-list/m-p/640209#M190622</guid>
      <dc:creator>buddha_d</dc:creator>
      <dc:date>2020-04-15T20:33:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate sequencial macro variable names and how to list them short in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-sequencial-macro-variable-names-and-how-to-list/m-p/640210#M190623</link>
      <description>thanks for your input</description>
      <pubDate>Wed, 15 Apr 2020 20:33:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-generate-sequencial-macro-variable-names-and-how-to-list/m-p/640210#M190623</guid>
      <dc:creator>buddha_d</dc:creator>
      <dc:date>2020-04-15T20:33:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate sequencial macro variable names and how to list them short in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-sequencial-macro-variable-names-and-how-to-list/m-p/640211#M190624</link>
      <description>Thanks for your inputs ballardw.</description>
      <pubDate>Wed, 15 Apr 2020 20:33:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-generate-sequencial-macro-variable-names-and-how-to-list/m-p/640211#M190624</guid>
      <dc:creator>buddha_d</dc:creator>
      <dc:date>2020-04-15T20:33:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate sequencial macro variable names and how to list them short in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-sequencial-macro-variable-names-and-how-to-list/m-p/640212#M190625</link>
      <description>Thanks PaigeMiller. It worked like Charm. I really appreciate it.</description>
      <pubDate>Wed, 15 Apr 2020 20:34:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-generate-sequencial-macro-variable-names-and-how-to-list/m-p/640212#M190625</guid>
      <dc:creator>buddha_d</dc:creator>
      <dc:date>2020-04-15T20:34:37Z</dc:date>
    </item>
  </channel>
</rss>

