<?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 and Proc SQL in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Macro-and-Proc-SQL/m-p/42378#M11029</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to collect the data from the SQL server. Because, I would need to repeat it for many times, I have to write a macro like the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro _input (table=, input=);&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;/P&gt;&lt;P&gt;CONNECT TO xxxx as xxxx (NOPROMPT= "DSN=xxxx;SERVER=xxxx;UID=;PWD=;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;DATABASE=xxxx");&lt;/P&gt;&lt;P&gt;CREATE TABLE website.&amp;amp;table. AS&lt;/P&gt;&lt;P&gt;SELECT * FROM CONNECTION TO xxxx&lt;/P&gt;&lt;P&gt;(&amp;amp;input.); &lt;/P&gt;&lt;P&gt;QUIT;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where xxxx is the connection information to the SQL server.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Table is just the table name and input would be sth. like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select abc, sum(def) as ddd from abc where abc like '%bb%' group by abc&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I put all the data into the table and try to run the macro but it fail.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to know is it possible to put the whole SQL script as an input value of a macro.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 07 Nov 2011 12:09:32 GMT</pubDate>
    <dc:creator>iusing</dc:creator>
    <dc:date>2011-11-07T12:09:32Z</dc:date>
    <item>
      <title>Macro and Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Macro-and-Proc-SQL/m-p/42378#M11029</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to collect the data from the SQL server. Because, I would need to repeat it for many times, I have to write a macro like the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro _input (table=, input=);&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;/P&gt;&lt;P&gt;CONNECT TO xxxx as xxxx (NOPROMPT= "DSN=xxxx;SERVER=xxxx;UID=;PWD=;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;DATABASE=xxxx");&lt;/P&gt;&lt;P&gt;CREATE TABLE website.&amp;amp;table. AS&lt;/P&gt;&lt;P&gt;SELECT * FROM CONNECTION TO xxxx&lt;/P&gt;&lt;P&gt;(&amp;amp;input.); &lt;/P&gt;&lt;P&gt;QUIT;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where xxxx is the connection information to the SQL server.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Table is just the table name and input would be sth. like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select abc, sum(def) as ddd from abc where abc like '%bb%' group by abc&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I put all the data into the table and try to run the macro but it fail.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to know is it possible to put the whole SQL script as an input value of a macro.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Nov 2011 12:09:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Macro-and-Proc-SQL/m-p/42378#M11029</guid>
      <dc:creator>iusing</dc:creator>
      <dc:date>2011-11-07T12:09:32Z</dc:date>
    </item>
    <item>
      <title>Macro and Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Macro-and-Proc-SQL/m-p/42379#M11030</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One easier (I think) possibility would be to build a data _null_ datastep with two things: (1) a call execute statement to run your proc sql commands and inserting (2) the two variables (i.e., tablename and selectlist) that you would list in the datalines.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Nov 2011 14:50:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Macro-and-Proc-SQL/m-p/42379#M11030</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-11-07T14:50:36Z</dc:date>
    </item>
    <item>
      <title>Macro and Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Macro-and-Proc-SQL/m-p/42380#M11031</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have try to do so but it doesn't work and said there is problem around the sum function.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Nov 2011 14:57:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Macro-and-Proc-SQL/m-p/42380#M11031</guid>
      <dc:creator>iusing</dc:creator>
      <dc:date>2011-11-07T14:57:41Z</dc:date>
    </item>
    <item>
      <title>Macro and Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Macro-and-Proc-SQL/m-p/42381#M11032</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It would help if you posted your code and log.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Nov 2011 14:59:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Macro-and-Proc-SQL/m-p/42381#M11032</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-11-07T14:59:36Z</dc:date>
    </item>
    <item>
      <title>Macro and Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Macro-and-Proc-SQL/m-p/42382#M11033</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="background-color: #eef4f9;"&gt;%macro _input (table=, input=);&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;PROC SQL;&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;CONNECT TO xxxx as xxxx (NOPROMPT= "DSN=xxxx;SERVER=xxxx;UID=;PWD=;&amp;nbsp; &lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;DATABASE=xxxx");&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;CREATE TABLE website.&amp;amp;table. AS&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;SELECT * FROM CONNECTION TO xxxx&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;(&amp;amp;input.);&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;QUIT;&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;Input_Table:&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;Table&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Input&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;bb&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Select abc, sum(def) as ddd from abc where abc like '%bb%' group by abc&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;dd&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Select abc, sum(def) as ddd from abc where abc like '%dd%' group by abc&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;data _null_ ;&lt;/P&gt;&lt;P&gt;set input_table;&lt;/P&gt;&lt;P&gt;call execute ('%_input (table='||Table||',input='||Input||')');&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Nov 2011 15:24:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Macro-and-Proc-SQL/m-p/42382#M11033</guid>
      <dc:creator>iusing</dc:creator>
      <dc:date>2011-11-07T15:24:50Z</dc:date>
    </item>
    <item>
      <title>Macro and Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Macro-and-Proc-SQL/m-p/42383#M11034</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I was suggesting something more like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; informat selections $100.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input table $ selections &amp;amp;;&lt;/P&gt;&lt;P&gt;&amp;nbsp; call execute('PROC SQL;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CREATE TABLE '||table||' AS '||&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; selections||'; QUIT;');&lt;/P&gt;&lt;P&gt;&amp;nbsp; cards;&lt;/P&gt;&lt;P&gt;aa&amp;nbsp; select name, sum(height) as ddd from sashelp.class where name like '%A%' group by name&lt;/P&gt;&lt;P&gt;jj&amp;nbsp; select name, sum(height) as ddd from sashelp.class where name like '%J%' group by name&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Nov 2011 15:58:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Macro-and-Proc-SQL/m-p/42383#M11034</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-11-07T15:58:30Z</dc:date>
    </item>
    <item>
      <title>Macro and Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Macro-and-Proc-SQL/m-p/42384#M11035</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Maybe should like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;Input_Table:&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;Table&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Input&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;bb&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;%nrstr&lt;/STRONG&gt;(Select abc, sum(def) as ddd from abc where abc like '%bb%' group by abc)&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;dd&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;%nrstr&lt;/STRONG&gt;( Select abc, sum(def) as ddd from abc where abc like '%dd%' group by abc)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Nov 2011 03:00:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Macro-and-Proc-SQL/m-p/42384#M11035</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-11-08T03:00:27Z</dc:date>
    </item>
    <item>
      <title>Macro and Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Macro-and-Proc-SQL/m-p/42385#M11036</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;put &lt;STRONG&gt;only &lt;/STRONG&gt;the create table statement in the macro&lt;/P&gt;&lt;P&gt;Make and break the connection outside the macro, like:&lt;/P&gt;&lt;P&gt;%macro _input (table=, input=);&lt;/P&gt;&lt;P&gt;CREATE TABLE website.&amp;amp;table. AS SELECT * FROM CONNECTION TO xxxx (&amp;amp;input.); &lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;/P&gt;&lt;P&gt;CONNECT TO xxxx as xxxx (NOPROMPT= "DSN=xxxx;SERVER=xxxx;UID=;PWD=; DATABASE=xxxx");&lt;/P&gt;&lt;P&gt;%input( table= xxxxxxxxxxxxxx, input= yyyyyyyyyyyyyyyyyyyyy );&lt;/P&gt;&lt;P&gt;%input( table= xxxxxxxxxxxxxx, input= yyyyyyyyyyyyyyyyyyyyy );&lt;/P&gt;&lt;P&gt;%input( table= xxxxxxxxxxxxxx, input= yyyyyyyyyyyyyyyyyyyyy );&lt;/P&gt;&lt;P&gt;%input( table= xxxxxxxxxxxxxx, input= yyyyyyyyyyyyyyyyyyyyy );&lt;/P&gt;&lt;P&gt;%input( table= xxxxxxxxxxxxxx, input= yyyyyyyyyyyyyyyyyyyyy );&lt;/P&gt;&lt;P&gt;%input( table= xxxxxxxxxxxxxx, input= yyyyyyyyyyyyyyyyyyyyy );&lt;/P&gt;&lt;P&gt;disconnect from xxxx ;&lt;/P&gt;&lt;P&gt;QUIT;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Nov 2011 21:37:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Macro-and-Proc-SQL/m-p/42385#M11036</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2011-11-09T21:37:31Z</dc:date>
    </item>
  </channel>
</rss>

