<?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 Conditional merge If table exists in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Conditional-merge-If-table-exists/m-p/481349#M124490</link>
    <description>&lt;P&gt;&lt;BR /&gt;Hello I have the following question.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I have a data set called 'tbl1' which contain fields: x,y1,y2.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Sometimes there another data set called "recovery_tbl' which contain fields: x,w,y1,y2&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;If in specific field all values are missing(null values in all columns) then If a recovery data set exists it will gather the values from there.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data tbl1;
input ID  y1  y2;
cards;
1 10 .
2 20 .
3 30 .
4 40 .
5 50 .
;
Run;
Data recovery_tbl;
input ID w y1  y2;
cards;
1 5 10 100
2 6 20 200
3 7 30 300
4 8 40 400
5 9 50 500
;
Run;
PROC SQL;
	create table tbl1_new as
	select a.ID,a.Y1,coalesce(a.Y2,b.Y2) as Y2	   
	from tbl1 as a
	left join recovery_tbl as b
	on a.ID=b.ID
;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;Can anyone how to perform this conditional merge. The merge need to be done only if 2 conditions happens: 1-There is a field that all values are null (missing values) 2- A recover table exists&lt;/P&gt;</description>
    <pubDate>Thu, 26 Jul 2018 06:07:39 GMT</pubDate>
    <dc:creator>Ronein</dc:creator>
    <dc:date>2018-07-26T06:07:39Z</dc:date>
    <item>
      <title>Conditional merge If table exists</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-merge-If-table-exists/m-p/481349#M124490</link>
      <description>&lt;P&gt;&lt;BR /&gt;Hello I have the following question.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I have a data set called 'tbl1' which contain fields: x,y1,y2.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Sometimes there another data set called "recovery_tbl' which contain fields: x,w,y1,y2&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;If in specific field all values are missing(null values in all columns) then If a recovery data set exists it will gather the values from there.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data tbl1;
input ID  y1  y2;
cards;
1 10 .
2 20 .
3 30 .
4 40 .
5 50 .
;
Run;
Data recovery_tbl;
input ID w y1  y2;
cards;
1 5 10 100
2 6 20 200
3 7 30 300
4 8 40 400
5 9 50 500
;
Run;
PROC SQL;
	create table tbl1_new as
	select a.ID,a.Y1,coalesce(a.Y2,b.Y2) as Y2	   
	from tbl1 as a
	left join recovery_tbl as b
	on a.ID=b.ID
;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;Can anyone how to perform this conditional merge. The merge need to be done only if 2 conditions happens: 1-There is a field that all values are null (missing values) 2- A recover table exists&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jul 2018 06:07:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-merge-If-table-exists/m-p/481349#M124490</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2018-07-26T06:07:39Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional merge If table exists</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-merge-If-table-exists/m-p/481364#M124499</link>
      <description>&lt;P&gt;Two questions, just to clarify what is needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If only some of the y2 values are missing from TBL1, would you like to use TBL1 as is (including those missing values)?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you guaranteed that each table contains exactly one observation per ID?&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jul 2018 07:16:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-merge-If-table-exists/m-p/481364#M124499</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-07-26T07:16:46Z</dc:date>
    </item>
  </channel>
</rss>

