<?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: combining multiple tables(qty=various) in one dataset/table by using macro. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/combining-multiple-tables-qty-various-in-one-dataset-table-by/m-p/563218#M157862</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you much, that is close but seems not exactly what I wanted to get.&lt;/P&gt;&lt;P&gt;On both your scripts I am getting 18 rows in a11, but i wish to get only 2 rows:&lt;/P&gt;&lt;P&gt;&amp;gt; DEC49, which is being got on JAN50 and&lt;/P&gt;&lt;P&gt;&amp;gt; JUN50, which is being got on JUL50&lt;/P&gt;</description>
    <pubDate>Mon, 03 Jun 2019 10:21:09 GMT</pubDate>
    <dc:creator>Ivan555</dc:creator>
    <dc:date>2019-06-03T10:21:09Z</dc:date>
    <item>
      <title>combining multiple tables(qty=various) in one dataset/table by using macro.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/combining-multiple-tables-qty-various-in-one-dataset-table-by/m-p/562778#M157698</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a goal to craft one table as an output of a several ones. The quantity of tables being combined may differ.&lt;/P&gt;&lt;P&gt;In accordance with the code, I would like to make a data "want" , which will include in itself all information of the tables "A11", being formed during the process.&amp;nbsp;The number of tables in not being fixed(in example qty=2) and may vary, so as a soluting i see a macro with do function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But.. I am thinking already rather much time, but i still cant catch an idea how could I to match all tables into one...&lt;/P&gt;&lt;P&gt;If anyone can help, i'll be very grateful.&lt;/P&gt;&lt;P&gt;(version SAS 9.4)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data input_dates;
length dt $9;
input dt;
dtnum +1;
datalines;
01JAN1950
01JUL1950
;
run;

proc sql noprint; select count(*) into: dtcnt from input_dates; quit;

%macro aaa;
%do i=1 %to &amp;amp;dtcnt;
proc sql noprint; select dt into: rdate from input_dates where dtnum = &amp;amp;dtcnt; quit;

proc sql;
    create table a1 as
    select date, air
    from sashelp.airline
    where date &amp;lt; "&amp;amp;rdate."d
    order by date desc;

    create table a11 as
    select date, air
    from a1(firstobs=1 obs=1);
quit;

data want;
merge a11;  /*i want here(or mabe in another place if need) to merge somehow all the tables with names a11*/
run;

%end
%mend aaa

%aaa&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;TY!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 31 May 2019 06:19:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/combining-multiple-tables-qty-various-in-one-dataset-table-by/m-p/562778#M157698</guid>
      <dc:creator>Ivan555</dc:creator>
      <dc:date>2019-05-31T06:19:51Z</dc:date>
    </item>
    <item>
      <title>Re: combining multiple tables(qty=various) in one dataset/table by using macro.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/combining-multiple-tables-qty-various-in-one-dataset-table-by/m-p/562780#M157699</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/272354"&gt;@Ivan555&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't really understand what you are trying to achieve with your code. But you can use the colon modifier as a wildcard to just address all tables that start with A11.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a11something;
  a=1;output;stop;
run;
data a11somethingelse;
  a=2;output;stop;
run;

data want;
  set a11:;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 31 May 2019 06:33:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/combining-multiple-tables-qty-various-in-one-dataset-table-by/m-p/562780#M157699</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-05-31T06:33:54Z</dc:date>
    </item>
    <item>
      <title>Re: combining multiple tables(qty=various) in one dataset/table by using macro.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/combining-multiple-tables-qty-various-in-one-dataset-table-by/m-p/562785#M157700</link>
      <description>&lt;P&gt;understood, thanks, i'll try to explain my idea more carefully.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;at start i do have&lt;BR /&gt;&amp;gt; a number of dates (input_dates), in example their quantity is 2, but in life it can vary.&lt;BR /&gt;&amp;gt; a table (sashelp.airline)&lt;BR /&gt;&amp;gt; and a condition on the table: to take most actual date &amp;lt; each input_date&amp;nbsp; according with the table - this is a result of A11.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the goal - is to save somewhere all the data from A11 tables(which are being rewrighting)&lt;/P&gt;</description>
      <pubDate>Fri, 31 May 2019 06:59:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/combining-multiple-tables-qty-various-in-one-dataset-table-by/m-p/562785#M157700</guid>
      <dc:creator>Ivan555</dc:creator>
      <dc:date>2019-05-31T06:59:19Z</dc:date>
    </item>
    <item>
      <title>Re: combining multiple tables(qty=various) in one dataset/table by using macro.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/combining-multiple-tables-qty-various-in-one-dataset-table-by/m-p/562786#M157701</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/272354"&gt;@Ivan555&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"&lt;EM&gt;and a condition on the table: to take most actual date &amp;lt; each input_date&lt;/EM&gt;"&lt;/P&gt;
&lt;P&gt;You have two input dates. What should happen if for a specific row in sashelp.airline the "actual date" is smaller than both input dates. Would you want to select the row once or twice? Would you want one or two rows in A11?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;On a side note: SAS Macro language is certainly not the right thing for your problem. This is about looking up values in a table for row selection in another table - something to be done via SAS data step or SQL.&lt;/P&gt;</description>
      <pubDate>Fri, 31 May 2019 07:11:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/combining-multiple-tables-qty-various-in-one-dataset-table-by/m-p/562786#M157701</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-05-31T07:11:36Z</dc:date>
    </item>
    <item>
      <title>Re: combining multiple tables(qty=various) in one dataset/table by using macro.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/combining-multiple-tables-qty-various-in-one-dataset-table-by/m-p/562797#M157709</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;According with example I do have&lt;BR /&gt;&lt;BR /&gt;1. date 01DEC1949 (received as the result of select on 01JAN1950)&lt;BR /&gt;2. date 01JUN1950 (received as the result of select on 01JUL1950)&lt;BR /&gt;&lt;BR /&gt;if 01DEC1949 &amp;lt; 01JUL1950(or&amp;nbsp;01JUN1950) - I am fine, this matters nothing for me&lt;BR /&gt;if we will take another example like dates (01JAN1950, 02JAN1950) and as the result of select we will get the same row (01DEC1949) for each of them, I am still fine with getting this row twice(plus this will happen seldom, the analog of "sashelp.airline" from my internal library is very dense)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am pretty new both in SAS and in SQL(working with them like for a month or two), so perhaps you are right.. I just thought macro is prefered in the case that the number of input dates may differ.. In life there can be 2 input dates, can be 10, can be 50..&lt;/P&gt;</description>
      <pubDate>Fri, 31 May 2019 08:09:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/combining-multiple-tables-qty-various-in-one-dataset-table-by/m-p/562797#M157709</guid>
      <dc:creator>Ivan555</dc:creator>
      <dc:date>2019-05-31T08:09:15Z</dc:date>
    </item>
    <item>
      <title>Re: combining multiple tables(qty=various) in one dataset/table by using macro.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/combining-multiple-tables-qty-various-in-one-dataset-table-by/m-p/562801#M157712</link>
      <description>&lt;P&gt;seems i've done what i want..&amp;nbsp;&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;don't know, mabe my code is not effective.. but seems it works.. solvation seems was in "proc append".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(data want = data&amp;nbsp;output_dates in my code)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data input_dates;
length dt $9;
input dt;
dtnum +1;
datalines;
01JAN1950
01JUL1950
;
run;
&lt;BR /&gt;data output_dates;&lt;BR /&gt;input DATE;&lt;BR /&gt;format DATE date9.;&lt;BR /&gt;input AIR;&lt;BR /&gt;format AIR int;&lt;BR /&gt;datalines;&lt;BR /&gt;;&lt;BR /&gt;&lt;BR /&gt;proc sql noprint; select count(*) into: dtcnt from input_dates; quit;

%macro aaa;
%do i=1 %to &amp;amp;dtcnt;
proc sql noprint; select dt into: rdate from input_dates where dtnum = &amp;amp;i; quit;

proc sql;
    create table a1 as
    select date, air
    from sashelp.airline
    where date &amp;lt; "&amp;amp;rdate."d
    order by date desc;

    create table a11 as
    select date, air
    from a1(firstobs=1 obs=1);
quit;

proc append base = output_dates data = a11;&lt;BR /&gt;run;&lt;BR /&gt;
%end
%mend aaa

%aaa&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 31 May 2019 09:28:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/combining-multiple-tables-qty-various-in-one-dataset-table-by/m-p/562801#M157712</guid>
      <dc:creator>Ivan555</dc:creator>
      <dc:date>2019-05-31T09:28:00Z</dc:date>
    </item>
    <item>
      <title>Re: combining multiple tables(qty=various) in one dataset/table by using macro.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/combining-multiple-tables-qty-various-in-one-dataset-table-by/m-p/562836#M157722</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/272354"&gt;@Ivan555&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The golden rule is: Only use SAS Macro code if you can't do it with regular SAS code.&lt;/P&gt;
&lt;P&gt;For your problem wouldn't below do it as well?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data input_dates;
  attrib dt length=8 format=date9.;
  input dt : date9.;
  datalines;
01JAN1950
01JUL1950
;
run;

proc sql;
  create table a11 as
  select date, air
  from sashelp.air o
  where exists
    (select * from input_dates i where o.date&amp;lt;i.dt)
  ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or given your logic - if I got this right - even something as simple as below should work.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  select max(dt) into :max_dt trimmed
  from input_dates
  ;
quit;

data a11;
  set sashelp.air(where=(date&amp;lt;&amp;amp;max_dt));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 31 May 2019 13:49:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/combining-multiple-tables-qty-various-in-one-dataset-table-by/m-p/562836#M157722</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-05-31T13:49:14Z</dc:date>
    </item>
    <item>
      <title>Re: combining multiple tables(qty=various) in one dataset/table by using macro.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/combining-multiple-tables-qty-various-in-one-dataset-table-by/m-p/562844#M157728</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you much for response, but i have to go..&lt;/P&gt;&lt;P&gt;i will study it and give you feedback on monday, sorry. &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 31 May 2019 14:01:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/combining-multiple-tables-qty-various-in-one-dataset-table-by/m-p/562844#M157728</guid>
      <dc:creator>Ivan555</dc:creator>
      <dc:date>2019-05-31T14:01:47Z</dc:date>
    </item>
    <item>
      <title>Re: combining multiple tables(qty=various) in one dataset/table by using macro.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/combining-multiple-tables-qty-various-in-one-dataset-table-by/m-p/563218#M157862</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you much, that is close but seems not exactly what I wanted to get.&lt;/P&gt;&lt;P&gt;On both your scripts I am getting 18 rows in a11, but i wish to get only 2 rows:&lt;/P&gt;&lt;P&gt;&amp;gt; DEC49, which is being got on JAN50 and&lt;/P&gt;&lt;P&gt;&amp;gt; JUN50, which is being got on JUL50&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jun 2019 10:21:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/combining-multiple-tables-qty-various-in-one-dataset-table-by/m-p/563218#M157862</guid>
      <dc:creator>Ivan555</dc:creator>
      <dc:date>2019-06-03T10:21:09Z</dc:date>
    </item>
    <item>
      <title>Re: combining multiple tables(qty=various) in one dataset/table by using macro.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/combining-multiple-tables-qty-various-in-one-dataset-table-by/m-p/563244#M157872</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/272354"&gt;@Ivan555&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you much, that is close but seems not exactly what I wanted to get.&lt;/P&gt;
&lt;P&gt;On both your scripts I am getting 18 rows in a11, but i wish to get only 2 rows:&lt;/P&gt;
&lt;P&gt;&amp;gt; DEC49, which is being got on JAN50 and&lt;/P&gt;
&lt;P&gt;&amp;gt; JUN50, which is being got on JUL50&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/272354"&gt;@Ivan555&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That's because I apparently don't understand the description of the logic you want to implement - especially below bit in red.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;at start i do have&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt; a number of dates (input_dates), in example their quantity is 2, but in life it can vary.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt; a table (sashelp.airline)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt; and a condition on the table: to take &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;most actual date &amp;lt; each input_date&lt;/STRONG&gt;&lt;/FONT&gt;&amp;nbsp; according with the table - this is a result of A11.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jun 2019 12:32:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/combining-multiple-tables-qty-various-in-one-dataset-table-by/m-p/563244#M157872</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-06-03T12:32:30Z</dc:date>
    </item>
    <item>
      <title>Re: combining multiple tables(qty=various) in one dataset/table by using macro.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/combining-multiple-tables-qty-various-in-one-dataset-table-by/m-p/563256#M157880</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt; being writing "date &amp;lt; each input_date" I will probably mean a list of dates &amp;lt; each input parameter&lt;BR /&gt;&amp;gt; being writing "most actual&amp;nbsp;date &amp;lt; each input_date" I will probably mean the most actual date in a list of dates &amp;lt;&amp;nbsp; each input parameter&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry, perhaps my English is also not enough good too.. &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jun 2019 13:54:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/combining-multiple-tables-qty-various-in-one-dataset-table-by/m-p/563256#M157880</guid>
      <dc:creator>Ivan555</dc:creator>
      <dc:date>2019-06-03T13:54:20Z</dc:date>
    </item>
  </channel>
</rss>

