<?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: Passing a SQL Query into a Macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Passing-a-SQL-Query-into-a-Macro/m-p/281061#M56921</link>
    <description>&lt;P&gt;You could probably solve it with a macro, but i can't see that it would&amp;nbsp;be simple...&lt;/P&gt;
&lt;P&gt;Perhaps there's another way?&lt;/P&gt;
&lt;P&gt;Describe your requirement in more detail, like&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Are A, B, C and D identical in structure?&lt;/LI&gt;
&lt;LI&gt;What does each table represent&amp;nbsp;(what differs them from the other ones)&lt;/LI&gt;
&lt;LI&gt;What is the business meaning of an intersection?&lt;/LI&gt;
&lt;LI&gt;How do you intend to use the result?&lt;/LI&gt;
&lt;/UL&gt;</description>
    <pubDate>Wed, 29 Jun 2016 12:32:45 GMT</pubDate>
    <dc:creator>LinusH</dc:creator>
    <dc:date>2016-06-29T12:32:45Z</dc:date>
    <item>
      <title>Passing a SQL Query into a Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Passing-a-SQL-Query-into-a-Macro/m-p/281030#M56912</link>
      <description>&lt;P&gt;I am trying to create a table with all the possible intersections of 4 tables in the same table with for example a colum that indicates the reference tables.&lt;/P&gt;&lt;P&gt;A with B&lt;/P&gt;&lt;P&gt;A with C&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;A with B with C with D&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can easily achive this but i dont want to create 15 tables and append in the end i would prefere to do this with a macro.&lt;/P&gt;&lt;P&gt;Is it possible?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the help i will leave the proc sql that i use to create one of the intersects.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table A as&lt;BR /&gt;select A.*,CAT(A.ID,' ',B.ID)AS MASTER_ID&lt;BR /&gt;from&lt;BR /&gt;work1 as A inner join&lt;BR /&gt;work2 as B on&amp;nbsp;...&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jun 2016 11:07:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Passing-a-SQL-Query-into-a-Macro/m-p/281030#M56912</guid>
      <dc:creator>Serafim12</dc:creator>
      <dc:date>2016-06-29T11:07:24Z</dc:date>
    </item>
    <item>
      <title>Re: Passing a SQL Query into a Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Passing-a-SQL-Query-into-a-Macro/m-p/281061#M56921</link>
      <description>&lt;P&gt;You could probably solve it with a macro, but i can't see that it would&amp;nbsp;be simple...&lt;/P&gt;
&lt;P&gt;Perhaps there's another way?&lt;/P&gt;
&lt;P&gt;Describe your requirement in more detail, like&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Are A, B, C and D identical in structure?&lt;/LI&gt;
&lt;LI&gt;What does each table represent&amp;nbsp;(what differs them from the other ones)&lt;/LI&gt;
&lt;LI&gt;What is the business meaning of an intersection?&lt;/LI&gt;
&lt;LI&gt;How do you intend to use the result?&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Wed, 29 Jun 2016 12:32:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Passing-a-SQL-Query-into-a-Macro/m-p/281061#M56921</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-06-29T12:32:45Z</dc:date>
    </item>
    <item>
      <title>Re: Passing a SQL Query into a Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Passing-a-SQL-Query-into-a-Macro/m-p/281066#M56922</link>
      <description>And, in addition to LinusH suggestion for more information about the tables and the requirements, another consideration is that you are not really "passing an SQL query" INTO a Macro. A Macro program definition only types/generates code for you. So your Macro program would only generate the code. Then the generated code goes to the compiler. The fact is that before you start with a macro program definition to generate SQL code, you have to start with a working program and then "macro-ize" the working program so that when you run the macro program, it generates the code you want. And, as LinusH suggests, by the time you write the working SQL query to do what you want, you might find that you don't need a Macro program at all. The only use for a macro program in an instance like this would be do allow you to generate the code many, many times and possibly alter the code, based on some condition or parameter that you pass in. So far, you haven't explained either of those usage scenarios. &lt;BR /&gt;&lt;BR /&gt;When I teach the Macro class I like to joke with my students that the SAS Macro facility is just a really big typewriter (if you remember those) and all it does is take symbolic parameters and conditional logic and make decisions that result in what code should be typed.&lt;BR /&gt;&lt;BR /&gt;cynthia</description>
      <pubDate>Wed, 29 Jun 2016 12:44:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Passing-a-SQL-Query-into-a-Macro/m-p/281066#M56922</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2016-06-29T12:44:15Z</dc:date>
    </item>
    <item>
      <title>Re: Passing a SQL Query into a Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Passing-a-SQL-Query-into-a-Macro/m-p/281082#M56928</link>
      <description>&lt;P&gt;Yea in structure they are identical just have an ID and a description of the group and each table represents different groups, the final result is a table that have the Count of ID's for each possible combination so in the end i would have a table like&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Combination&lt;/TD&gt;&lt;TD&gt;Count&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&amp;amp;B&lt;/TD&gt;&lt;TD&gt;100&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&amp;amp;C&lt;/TD&gt;&lt;TD&gt;200&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&amp;amp;B&amp;amp;C&lt;/TD&gt;&lt;TD&gt;50&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;…&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Wed, 29 Jun 2016 13:09:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Passing-a-SQL-Query-into-a-Macro/m-p/281082#M56928</guid>
      <dc:creator>Serafim12</dc:creator>
      <dc:date>2016-06-29T13:09:57Z</dc:date>
    </item>
    <item>
      <title>Re: Passing a SQL Query into a Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Passing-a-SQL-Query-into-a-Macro/m-p/281086#M56930</link>
      <description>&lt;P&gt;Since you plan on appending all the possible data sets back together again, you would be much better off with a single DATA step and a single variable to indicate matches/mismatches.&amp;nbsp; Assuming that your data sets are sorted first:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;merge a (in=in1) b (in=in2) c (in=in3) d (in=in4);&lt;/P&gt;
&lt;P&gt;by id;&lt;/P&gt;
&lt;P&gt;match = cats(of in1-in4);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jun 2016 13:16:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Passing-a-SQL-Query-into-a-Macro/m-p/281086#M56930</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-06-29T13:16:11Z</dc:date>
    </item>
  </channel>
</rss>

