<?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: Building macro in proc sql step in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Building-macro-in-proc-sql-step/m-p/609452#M177440</link>
    <description>&lt;P&gt;Do you want to generate code like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select * from table BIG where num in (select num from NUM1)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or code like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select * from table BIG where num in 
(102491
,127495
,145603
)&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 04 Dec 2019 17:24:53 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2019-12-04T17:24:53Z</dc:date>
    <item>
      <title>Building macro in proc sql step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Building-macro-in-proc-sql-step/m-p/609440#M177434</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have more than 10 different data set like the table below. I need to use those 10 different data set to build the query. Would you please help me to build a macro to pull the data set directly via query?&amp;nbsp; i have 10 different nums table and each of them has 1000 rows. Each num will be used in proc sql step to build another query like below. I would like to set up the query via macro step rather than pulling each query. Would you please help?&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;nums&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;102491&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;127495&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;145603&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;146082&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;151317&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;164886&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;164887&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;164888&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;169898&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;171675&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;174616&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;174617&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;176940&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;177503&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;184793&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Select * from table where num in (num1)&lt;/P&gt;&lt;P&gt;Select * from table where num in (num2)&lt;/P&gt;&lt;P&gt;Select * from table where num in (num3)&lt;/P&gt;&lt;P&gt;Select * from table where num in (num4)&lt;/P&gt;&lt;P&gt;Select * from table where num in (num5)&lt;/P&gt;&lt;P&gt;Select * from table where num in (num6)&lt;/P&gt;&lt;P&gt;Select * from table where num in (num7)&lt;/P&gt;&lt;P&gt;Select * from table where num in (num8)&lt;/P&gt;&lt;P&gt;Select * from table where num in (num9)&lt;/P&gt;&lt;P&gt;Select * from table where num in (num10)&lt;/P&gt;</description>
      <pubDate>Wed, 04 Dec 2019 16:26:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Building-macro-in-proc-sql-step/m-p/609440#M177434</guid>
      <dc:creator>niloya</dc:creator>
      <dc:date>2019-12-04T16:26:16Z</dc:date>
    </item>
    <item>
      <title>Re: Building macro in proc sql step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Building-macro-in-proc-sql-step/m-p/609441#M177435</link>
      <description>&lt;P&gt;If these many data sets are the result of your earlier question where you ask &lt;A href="https://communities.sas.com/t5/SAS-Programming/Splitting-big-data-set-into-equal-data-set/m-p/609430#M177433" target="_self"&gt;how to split the data into many data sets&lt;/A&gt;, you are going about this the wrong way, and making life harder for yourself. You really ought to consider keeping everything in one big data set and then you can perform analyses or other tasks using the BY statement, rather than writing loops.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Dec 2019 16:35:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Building-macro-in-proc-sql-step/m-p/609441#M177435</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-12-04T16:35:33Z</dc:date>
    </item>
    <item>
      <title>Re: Building macro in proc sql step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Building-macro-in-proc-sql-step/m-p/609445#M177438</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp; The system does not let me pull in data greater than 1000 rows. That is why i am splitting it to 1000 and then pulling it via query&lt;/P&gt;</description>
      <pubDate>Wed, 04 Dec 2019 16:59:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Building-macro-in-proc-sql-step/m-p/609445#M177438</guid>
      <dc:creator>niloya</dc:creator>
      <dc:date>2019-12-04T16:59:57Z</dc:date>
    </item>
    <item>
      <title>Re: Building macro in proc sql step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Building-macro-in-proc-sql-step/m-p/609450#M177439</link>
      <description>&lt;P&gt;What system is placing this limit on you?&amp;nbsp; SAS does not have any such limit.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Dec 2019 17:22:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Building-macro-in-proc-sql-step/m-p/609450#M177439</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-12-04T17:22:13Z</dc:date>
    </item>
    <item>
      <title>Re: Building macro in proc sql step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Building-macro-in-proc-sql-step/m-p/609452#M177440</link>
      <description>&lt;P&gt;Do you want to generate code like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select * from table BIG where num in (select num from NUM1)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or code like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select * from table BIG where num in 
(102491
,127495
,145603
)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 04 Dec 2019 17:24:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Building-macro-in-proc-sql-step/m-p/609452#M177440</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-12-04T17:24:53Z</dc:date>
    </item>
    <item>
      <title>Re: Building macro in proc sql step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Building-macro-in-proc-sql-step/m-p/609454#M177441</link>
      <description>&lt;P&gt;I am connecting different servers through SAS. It is winsql.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Dec 2019 17:27:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Building-macro-in-proc-sql-step/m-p/609454#M177441</guid>
      <dc:creator>niloya</dc:creator>
      <dc:date>2019-12-04T17:27:02Z</dc:date>
    </item>
    <item>
      <title>Re: Building macro in proc sql step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Building-macro-in-proc-sql-step/m-p/609455#M177442</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp; Thank you Tom. i prefered this one.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token statement"&gt;select&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;from&lt;/SPAN&gt; &lt;SPAN class="token statement"&gt;table&lt;/SPAN&gt; BIG &lt;SPAN class="token statement"&gt;where&lt;/SPAN&gt; num &lt;SPAN class="token operator"&gt;in&lt;/SPAN&gt; 
&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;102491&lt;/SPAN&gt;
&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;127495&lt;/SPAN&gt;
&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;145603&lt;/SPAN&gt;
&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Dec 2019 17:28:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Building-macro-in-proc-sql-step/m-p/609455#M177442</guid>
      <dc:creator>niloya</dc:creator>
      <dc:date>2019-12-04T17:28:03Z</dc:date>
    </item>
    <item>
      <title>Re: Building macro in proc sql step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Building-macro-in-proc-sql-step/m-p/609456#M177443</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/266639"&gt;@niloya&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am connecting different servers through SAS. It is winsql.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Move the list to the other server and then you can reference in the query you push to the other server.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Dec 2019 17:30:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Building-macro-in-proc-sql-step/m-p/609456#M177443</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-12-04T17:30:03Z</dc:date>
    </item>
    <item>
      <title>Re: Building macro in proc sql step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Building-macro-in-proc-sql-step/m-p/609459#M177444</link>
      <description>&lt;P&gt;If the BIG table has a lot of columns or multiple observations per value of NUM it is probably going to be a lot easier to instead move the list of numbers to the remote machine so it can be joined there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the values are actual numbers like in your example then you should be able to place all 1000 numbers into a single macro variable.&lt;/P&gt;
&lt;P&gt;So you could create 10 subsets of your remote database by generating 10 select statements like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL ;
   connect to ..... as MYDB ..... ;
%do i=1 %to 10 ;
   select num into :list separated by ',' from num&amp;amp;i;
   create table subset&amp;amp;i as select * from connection to mydb
  (select * from BIG where num in (&amp;amp;list)
  );
%end;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 04 Dec 2019 17:35:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Building-macro-in-proc-sql-step/m-p/609459#M177444</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-12-04T17:35:27Z</dc:date>
    </item>
    <item>
      <title>Re: Building macro in proc sql step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Building-macro-in-proc-sql-step/m-p/609462#M177446</link>
      <description>&lt;P&gt;Have that limit removed there. This is plain ridiculous.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/266639"&gt;@niloya&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp; The system does not let me pull in data greater than 1000 rows. That is why i am splitting it to 1000 and then pulling it via query&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Dec 2019 17:39:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Building-macro-in-proc-sql-step/m-p/609462#M177446</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-12-04T17:39:43Z</dc:date>
    </item>
    <item>
      <title>Re: Building macro in proc sql step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Building-macro-in-proc-sql-step/m-p/609475#M177453</link>
      <description>&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;Tutorial on converting a working program to a macro&lt;BR /&gt;&lt;BR /&gt;This method is pretty robust and helps prevent errors and makes it much easier to debug your code. Obviously biased, because I wrote it &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&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;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Dec 2019 18:35:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Building-macro-in-proc-sql-step/m-p/609475#M177453</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-12-04T18:35:16Z</dc:date>
    </item>
    <item>
      <title>Re: Building macro in proc sql step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Building-macro-in-proc-sql-step/m-p/609476#M177454</link>
      <description>&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;Tutorial on converting a working program to a macro&lt;BR /&gt;&lt;BR /&gt;This method is pretty robust and helps prevent errors and makes it much easier to debug your code. Obviously biased, because I wrote it &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&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;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Dec 2019 18:35:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Building-macro-in-proc-sql-step/m-p/609476#M177454</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-12-04T18:35:18Z</dc:date>
    </item>
  </channel>
</rss>

