<?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 Macro to run SQL with multiple values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-run-SQL-with-multiple-values/m-p/515307#M139005</link>
    <description>&lt;P&gt;I've one SQL which I'm currently executing multiple times with different values. For example, assume the SQL is executing with one condition (e.g. emp_id=123) and the next time I'm executing with emp_id=234 and so on to create multiple tables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can we achieve this task in macro to execute the SQL once by passing different values to create multiple tables? Any pointers to the documents will also helpful.&lt;/P&gt;</description>
    <pubDate>Thu, 22 Nov 2018 08:39:17 GMT</pubDate>
    <dc:creator>Babloo</dc:creator>
    <dc:date>2018-11-22T08:39:17Z</dc:date>
    <item>
      <title>Macro to run SQL with multiple values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-run-SQL-with-multiple-values/m-p/515307#M139005</link>
      <description>&lt;P&gt;I've one SQL which I'm currently executing multiple times with different values. For example, assume the SQL is executing with one condition (e.g. emp_id=123) and the next time I'm executing with emp_id=234 and so on to create multiple tables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can we achieve this task in macro to execute the SQL once by passing different values to create multiple tables? Any pointers to the documents will also helpful.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Nov 2018 08:39:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-run-SQL-with-multiple-values/m-p/515307#M139005</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2018-11-22T08:39:17Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to run SQL with multiple values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-run-SQL-with-multiple-values/m-p/515309#M139006</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro doSQL(id);

    SELECT *
    FROM aDataset
    WHERE emp_id=&amp;amp;id.;

%mend;

proc sql;

    %doSQL(123);

    %doSQL(456);

quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Why do you want to create separate datasets per id ? Depending on what you are trying to do, a single&lt;/P&gt;
&lt;P&gt;request with a GROUP BY statement could be a better solution.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Nov 2018 08:54:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-run-SQL-with-multiple-values/m-p/515309#M139006</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2018-11-22T08:54:34Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to run SQL with multiple values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-run-SQL-with-multiple-values/m-p/515311#M139008</link>
      <description>&lt;P&gt;"&lt;SPAN&gt;to create multiple tables" - really not a good idea, that is not thinking "the SAS way".&amp;nbsp; Just create grouping variables in the data for each group, and then use those grouping data for further processing.&amp;nbsp; E.g. you could loop over:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;- create dataset with subject data for 001&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;- print dataset with subject 001 data&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;- create dataset with subject 002&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;...&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Or you could simply say:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;- print big dataset by subject where subject in 001,002...&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;As such the question is moot, a change to the thought process removes the need for extra messy maintainable&amp;nbsp;code.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Nov 2018 09:10:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-run-SQL-with-multiple-values/m-p/515311#M139008</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-11-22T09:10:21Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to run SQL with multiple values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-run-SQL-with-multiple-values/m-p/515386#M139041</link>
      <description>&lt;P&gt;Here's a tutorial on making a macro:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://github.com/statgeek/SAS-Tutorials/blob/master/Turning%20a%20program%20into%20a%20macro.md" target="_blank"&gt;https://github.com/statgeek/SAS-Tutorials/blob/master/Turning%20a%20program%20into%20a%20macro.md&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Nov 2018 15:52:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-run-SQL-with-multiple-values/m-p/515386#M139041</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-11-22T15:52:04Z</dc:date>
    </item>
  </channel>
</rss>

