<?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 How to merge more than one data set and populate the values missing in a variable from another set in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-more-than-one-data-set-and-populate-the-values/m-p/352231#M82073</link>
    <description>&lt;P&gt;Dear,&lt;/P&gt;&lt;P&gt;I am merging three dataset to populate missing 'age' variable values with values two and three sets. With my code the values are not populated. &amp;nbsp;I written a sql code to reduce my code. Please suggest in my code Thank you very much.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data one;
input id age;
datalines;
1 50
2 40
3 .
4 30
5 .
6 70
;
data two;
input id age;
datalines;
1 50
2 40
3 80
;
data three;
input id age;
datalines;
4 30
5 60
6 70
;
proc sql;
create table four as
select *
from ( select * from one as a left join two as b
on a.id=b.id) as a left join three as c
on a.id=c.id
order by id;
quit;&lt;/PRE&gt;</description>
    <pubDate>Fri, 21 Apr 2017 16:11:48 GMT</pubDate>
    <dc:creator>knveraraju91</dc:creator>
    <dc:date>2017-04-21T16:11:48Z</dc:date>
    <item>
      <title>How to merge more than one data set and populate the values missing in a variable from another set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-more-than-one-data-set-and-populate-the-values/m-p/352231#M82073</link>
      <description>&lt;P&gt;Dear,&lt;/P&gt;&lt;P&gt;I am merging three dataset to populate missing 'age' variable values with values two and three sets. With my code the values are not populated. &amp;nbsp;I written a sql code to reduce my code. Please suggest in my code Thank you very much.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data one;
input id age;
datalines;
1 50
2 40
3 .
4 30
5 .
6 70
;
data two;
input id age;
datalines;
1 50
2 40
3 80
;
data three;
input id age;
datalines;
4 30
5 60
6 70
;
proc sql;
create table four as
select *
from ( select * from one as a left join two as b
on a.id=b.id) as a left join three as c
on a.id=c.id
order by id;
quit;&lt;/PRE&gt;</description>
      <pubDate>Fri, 21 Apr 2017 16:11:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-more-than-one-data-set-and-populate-the-values/m-p/352231#M82073</guid>
      <dc:creator>knveraraju91</dc:creator>
      <dc:date>2017-04-21T16:11:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge more than one data set and populate the values missing in a variable from another s</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-more-than-one-data-set-and-populate-the-values/m-p/352232#M82074</link>
      <description>&lt;P&gt;And what do you think the resulting warnings in the log mean?&lt;/P&gt;
&lt;PRE&gt;WARNING: Column named id is duplicated in a select expression (or a view). Explicit references to
         it will be to the first one.
WARNING: Column named id is duplicated in a select expression (or a view). Explicit references to
         it will be to the first one.
WARNING: Variable id already exists on file USER.FOUR.
WARNING: Variable age already exists on file USER.FOUR.
WARNING: Variable id already exists on file USER.FOUR.
WARNING: Variable age already exists on file USER.FOUR.
&lt;/PRE&gt;
&lt;P&gt;Since you did nothing in the main (first) select then you told the procedure to only keep the first variable of&amp;nbsp; the same name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might want to start again with something like:&lt;/P&gt;
&lt;PRE&gt;proc sql;
create table four as
select *
from ( select * from one as a left join (select id,age as ageb from two) as b
on a.id=b.id) as a left join (select id, age as agec from three) as c
on a.id=c.id
order by id;
quit;&lt;/PRE&gt;
&lt;P&gt;Or two data set UPDATES if the main data that needs changes does not have repeats of the ID variable(s)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Apr 2017 16:18:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-more-than-one-data-set-and-populate-the-values/m-p/352232#M82074</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-04-21T16:18:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge more than one data set and populate the values missing in a variable from another s</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-more-than-one-data-set-and-populate-the-values/m-p/352233#M82075</link>
      <description>&lt;P&gt;You haven't told us enough.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What should happen if two of your data sets have different values for AGE for the same ID? &amp;nbsp;Which AGE do you want?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In real life, do any of the data sets contain additional variables?&lt;/P&gt;</description>
      <pubDate>Fri, 21 Apr 2017 16:25:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-more-than-one-data-set-and-populate-the-values/m-p/352233#M82075</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-04-21T16:25:50Z</dc:date>
    </item>
  </channel>
</rss>

