<?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: merge data Table in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/merge-data-Table/m-p/433963#M107667</link>
    <description>&lt;P&gt;I have created a simple macro. You can use it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro tablesize(tablename=);
	proc sql noprint;
	select count(*) into :cnt from &amp;amp;tablename.;
	quit;
	%if &amp;amp;cnt. ne 0 %then %do;
		%let &amp;amp;tablename.=&amp;amp;tablename.;
	%end;
	%else %do;
		%let &amp;amp;tablename.=;
	%end;
%mend tablesize;

%tablesize(tablename=A);
%tablesize(tablename=B);
%tablesize(tablename=C);

data d;
merge &amp;amp;A. &amp;amp;B. &amp;amp;C.;
by common_var;
run;

/*Which of the table is empty its corresponding macro will be initialized to null 
so they wont be merged in the data step as the macro resoves to null
Remember to call macronames insted of tablenames.
Remember Not to have any macro variable same name as tablenames*/&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Please let us know if it worked for you.&lt;/P&gt;</description>
    <pubDate>Sun, 04 Feb 2018 14:51:31 GMT</pubDate>
    <dc:creator>Satish_Parida</dc:creator>
    <dc:date>2018-02-04T14:51:31Z</dc:date>
    <item>
      <title>merge data Table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/merge-data-Table/m-p/433937#M107654</link>
      <description>&lt;P&gt;How to merge non-empty tables only? skip empty tables.&lt;/P&gt;</description>
      <pubDate>Sun, 04 Feb 2018 04:05:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/merge-data-Table/m-p/433937#M107654</guid>
      <dc:creator>invitro</dc:creator>
      <dc:date>2018-02-04T04:05:30Z</dc:date>
    </item>
    <item>
      <title>Re: merge data Table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/merge-data-Table/m-p/433939#M107655</link>
      <description>&lt;P&gt;In what way are empty datasets causing a problem during your merge operation. In the following example, merging with an empty dataset isn't a problem, except for the presence of an empty column&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
id=1; x=1; output;
id=1; x=2; output;
run;

/* Empty dataset */
data b;
length id x y 8;
stop;
run;

data c;
id=1; z=3; output;
id=1; z=4; output;
run;

data d;
merge a b c;
by id;
run;

proc print data=d noobs; run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;                                 id    x    y    z

                                  1    1    .    3
                                  1    2    .    4
&lt;/PRE&gt;</description>
      <pubDate>Sun, 04 Feb 2018 04:41:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/merge-data-Table/m-p/433939#M107655</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-02-04T04:41:41Z</dc:date>
    </item>
    <item>
      <title>Re: merge data Table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/merge-data-Table/m-p/433963#M107667</link>
      <description>&lt;P&gt;I have created a simple macro. You can use it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro tablesize(tablename=);
	proc sql noprint;
	select count(*) into :cnt from &amp;amp;tablename.;
	quit;
	%if &amp;amp;cnt. ne 0 %then %do;
		%let &amp;amp;tablename.=&amp;amp;tablename.;
	%end;
	%else %do;
		%let &amp;amp;tablename.=;
	%end;
%mend tablesize;

%tablesize(tablename=A);
%tablesize(tablename=B);
%tablesize(tablename=C);

data d;
merge &amp;amp;A. &amp;amp;B. &amp;amp;C.;
by common_var;
run;

/*Which of the table is empty its corresponding macro will be initialized to null 
so they wont be merged in the data step as the macro resoves to null
Remember to call macronames insted of tablenames.
Remember Not to have any macro variable same name as tablenames*/&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Please let us know if it worked for you.&lt;/P&gt;</description>
      <pubDate>Sun, 04 Feb 2018 14:51:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/merge-data-Table/m-p/433963#M107667</guid>
      <dc:creator>Satish_Parida</dc:creator>
      <dc:date>2018-02-04T14:51:31Z</dc:date>
    </item>
    <item>
      <title>Re: merge data Table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/merge-data-Table/m-p/434005#M107676</link>
      <description>&lt;P&gt;Thank you, PG. There is no issue to merge empty tables. I just don't want to keep columns from empty tables.&lt;/P&gt;</description>
      <pubDate>Sun, 04 Feb 2018 20:21:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/merge-data-Table/m-p/434005#M107676</guid>
      <dc:creator>invitro</dc:creator>
      <dc:date>2018-02-04T20:21:03Z</dc:date>
    </item>
    <item>
      <title>Re: merge data Table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/merge-data-Table/m-p/434006#M107677</link>
      <description>Thank you, Satish_Parida. It should work.</description>
      <pubDate>Sun, 04 Feb 2018 20:21:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/merge-data-Table/m-p/434006#M107677</guid>
      <dc:creator>invitro</dc:creator>
      <dc:date>2018-02-04T20:21:57Z</dc:date>
    </item>
  </channel>
</rss>

