<?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 read multiple dataset with Macro Variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-multiple-dataset-with-Macro-Variable/m-p/304880#M64951</link>
    <description>&lt;P&gt;There is a limit to the number of tables that a single SQL statement can use.&lt;/P&gt;
&lt;P&gt;Why are you using SQL instead of a DATA step? &amp;nbsp;You can merge hundreds of datasets with a single data step if you want.&lt;/P&gt;</description>
    <pubDate>Sat, 15 Oct 2016 19:49:38 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2016-10-15T19:49:38Z</dc:date>
    <item>
      <title>How to read multiple dataset with Macro Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-multiple-dataset-with-Macro-Variable/m-p/304879#M64950</link>
      <description>&lt;P&gt;Dear All,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have written a proc statement in SAS as below:&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;create table var.ACXMSR_MKEPUBSUB as&lt;BR /&gt;select a.INDIV_ID, a.MSR_INDIV_ID, b.ROLE_CD, b.SUB_ORDER_NBR, b.AGENCY_CD, b.SUB_ORDER_DT, b.PAID_AMT, b.PROD_ID, b.CANCEL_DT, b.SOURCE_RECEIVED_CD, b.PAYMENT_DT,&lt;BR /&gt;b.PAYMENT_STATUS_CD, b.PAYMENT_TYPE_MKE_CD, b.ORDER_DOCUMENT_KEY_CD, b.CANCEL_TYPE_CD&lt;BR /&gt;from var.FF_ACX_MSR_ID10 a, ora1.FACT_MKE_PUB_SUBSCRIPTION b&lt;BR /&gt;where a.MSR_INDIV_ID = b.INDIVIDUAL_ID;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the where clause i have mentioned 2 data tables however like this i have 100 data tables as we are migrating from Oracle to SAS hence it is very tedious to keep writing this code again and again, also the data is huge 200+ GB hence i thought of using a macro.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Before the code proc sql, i am thinking of using % let statement like&lt;/P&gt;
&lt;P&gt;% let newvar = name of dataset ; &lt;/P&gt;
&lt;P&gt;%let newvar1 = name of other dataset;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i plan to call these in the proc sql statement in the where clause, Please advice if this approach is correct or i should go for some other approach.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 15 Oct 2016 19:00:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-multiple-dataset-with-Macro-Variable/m-p/304879#M64950</guid>
      <dc:creator>Shivi82</dc:creator>
      <dc:date>2016-10-15T19:00:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to read multiple dataset with Macro Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-multiple-dataset-with-Macro-Variable/m-p/304880#M64951</link>
      <description>&lt;P&gt;There is a limit to the number of tables that a single SQL statement can use.&lt;/P&gt;
&lt;P&gt;Why are you using SQL instead of a DATA step? &amp;nbsp;You can merge hundreds of datasets with a single data step if you want.&lt;/P&gt;</description>
      <pubDate>Sat, 15 Oct 2016 19:49:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-multiple-dataset-with-Macro-Variable/m-p/304880#M64951</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2016-10-15T19:49:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to read multiple dataset with Macro Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-multiple-dataset-with-Macro-Variable/m-p/304882#M64952</link>
      <description>&lt;P&gt;HI,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I do not have to merge the data sets.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As said one table is in Oracle and other in SAS hence with the proc sql statement i am picking one variable from Oracle data table &amp;nbsp;and similar variable from SAS table say individual id and fnding the difference in count for each variable.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 15 Oct 2016 20:28:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-multiple-dataset-with-Macro-Variable/m-p/304882#M64952</guid>
      <dc:creator>Shivi82</dc:creator>
      <dc:date>2016-10-15T20:28:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to read multiple dataset with Macro Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-multiple-dataset-with-Macro-Variable/m-p/304883#M64953</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a quick intro to macro page that can help you get started&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.ats.ucla.edu/stat/sas/seminars/sas_macros_introduction/" target="_blank"&gt;http://www.ats.ucla.edu/stat/sas/seminars/sas_macros_introduction/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Depending on how big your data table A is, you may want to consider a macro variable with IDs listed instead. Then the entire query can run on the server. When SAS has to use data on a server and some other location ALL the data is first brought into SAS and then filtered/analyzed.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 15 Oct 2016 21:34:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-multiple-dataset-with-Macro-Variable/m-p/304883#M64953</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-10-15T21:34:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to read multiple dataset with Macro Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-multiple-dataset-with-Macro-Variable/m-p/304892#M64962</link>
      <description>&lt;P&gt;Are the variable names always the same ... just the table names that are changing?&lt;/P&gt;</description>
      <pubDate>Sat, 15 Oct 2016 23:22:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-multiple-dataset-with-Macro-Variable/m-p/304892#M64962</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-10-15T23:22:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to read multiple dataset with Macro Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-multiple-dataset-with-Macro-Variable/m-p/304893#M64963</link>
      <description>&lt;P&gt;Yes correct, the variable names are always the same. it is just that the table names change.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 15 Oct 2016 23:35:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-multiple-dataset-with-Macro-Variable/m-p/304893#M64963</guid>
      <dc:creator>Shivi82</dc:creator>
      <dc:date>2016-10-15T23:35:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to read multiple dataset with Macro Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-multiple-dataset-with-Macro-Variable/m-p/304899#M64966</link>
      <description>&lt;P&gt;Below some sample code how you can execute the same code using different table names.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro demo(tbl_name);
  title "Table is: &amp;amp;tbl_name";
  proc print data=&amp;amp;tbl_name;
  run;
%mend;

data _null_;
  input table :$41.;
  call execute('%demo('||table||')');
  datalines;
sashelp.class
sashelp.company
;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Given the volumes you're dealing with also consider if you can eventually do the counts first separately within SAS and Oracle and only then combine the results over your grouping variables. This would reduce data volumes exchanged between SAS and Oracle and though improve performance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From&amp;nbsp;what you've told us I also believe that you would have to use a full outer join instead of an implicit inner join (your Where clause).&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 16 Oct 2016 02:20:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-multiple-dataset-with-Macro-Variable/m-p/304899#M64966</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2016-10-16T02:20:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to read multiple dataset with Macro Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-multiple-dataset-with-Macro-Variable/m-p/304920#M64981</link>
      <description>&lt;P&gt;While CALL EXECUTE is a valuable tool, it's probably 2 or 3 steps beyond where you are right now &amp;nbsp;Here's a more basic approach. &amp;nbsp;First, define a macro:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro one_run (dataset1=, dataset2=);&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;create table var.ACXMSR_MKEPUBSUB as&lt;BR /&gt;select a.INDIV_ID, a.MSR_INDIV_ID, b.ROLE_CD, b.SUB_ORDER_NBR, b.AGENCY_CD, b.SUB_ORDER_DT, b.PAID_AMT, b.PROD_ID, b.CANCEL_DT, b.SOURCE_RECEIVED_CD, b.PAYMENT_DT,&lt;BR /&gt;b.PAYMENT_STATUS_CD, b.PAYMENT_TYPE_MKE_CD, b.ORDER_DOCUMENT_KEY_CD, b.CANCEL_TYPE_CD&lt;BR /&gt;from &amp;amp;dataset1 a, &amp;amp;dataset2 b&lt;BR /&gt;where a.MSR_INDIV_ID = b.INDIVIDUAL_ID;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;%mend one_run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then run the macro as many times as necessary. &amp;nbsp;One line of 100:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%one_run (dataset1=&lt;SPAN&gt;var.FF_ACX_MSR_ID10, dataset2=ora1.FACT_MKE_PUB_SUBSCRIPTION)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that the text substitution does not take place in the WHERE clause. &amp;nbsp;Rather, it takes place just before that when defining the aliases "a" and "b".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To automate this process with CALL EXECUTE, &amp;nbsp;you would need (1) the macro definition, plus (b) a SAS data set holding the pairs of data set names. &amp;nbsp;CALL EXECUTE could automate calling the macro 100 times. &amp;nbsp;So if you already have the list of data set names as a DATA data set, CALL EXECUTE helps. &amp;nbsp;But if you don't already have a SAS data set with the pairs of data set names, it's just as easy to call the macro 100 times.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 16 Oct 2016 11:48:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-multiple-dataset-with-Macro-Variable/m-p/304920#M64981</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-10-16T11:48:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to read multiple dataset with Macro Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-multiple-dataset-with-Macro-Variable/m-p/304921#M64982</link>
      <description>&lt;P&gt;Hi Patrick,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for the explanation and code. This is very helpful.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 16 Oct 2016 12:00:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-multiple-dataset-with-Macro-Variable/m-p/304921#M64982</guid>
      <dc:creator>Shivi82</dc:creator>
      <dc:date>2016-10-16T12:00:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to read multiple dataset with Macro Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-multiple-dataset-with-Macro-Variable/m-p/304922#M64983</link>
      <description>&lt;P&gt;This is so simple and this is what i was looking for. I dont recall any other forum taking so much pain to explain the code and process in detail.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you all for extending support. This is one reason as&amp;nbsp;to why i believe no other software can come closer to SAS as this is one awesome community.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers...&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 16 Oct 2016 12:11:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-multiple-dataset-with-Macro-Variable/m-p/304922#M64983</guid>
      <dc:creator>Shivi82</dc:creator>
      <dc:date>2016-10-16T12:11:06Z</dc:date>
    </item>
  </channel>
</rss>

