<?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: join or merge by using some information in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/join-or-merge-by-using-some-information/m-p/718373#M222322</link>
    <description>&lt;P&gt;According to ID=4 wanted output it seems that you select DEATH only from have1 and neglect it from have2. Try next code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  create table want as
  select a.ID, a.year, a.reg, a. sex, a.incs,
            b.death
  from have2 as a
  left join have1 as b
  on a.ID = b.ID;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 10 Feb 2021 19:45:18 GMT</pubDate>
    <dc:creator>Shmuel</dc:creator>
    <dc:date>2021-02-10T19:45:18Z</dc:date>
    <item>
      <title>join or merge by using some information</title>
      <link>https://communities.sas.com/t5/SAS-Programming/join-or-merge-by-using-some-information/m-p/718330#M222295</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have1;
 input id year death reg;
 datalines;
1 2000 0 11
1 2001 0 12
1 2002 0 11
1 2003 0 11
2 2000 1 11
2 2001 1 12
2 2002 1 13
2 2003 1 14
3 2000 0 . 
3 2001 0 11
3 2002 0 11
3 2003 0 11
5 2000 1 . 
5 2001 1 . 
5 2002 1 11
5 2003 1 11
;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have2;
input id year reg sex incs;
datalines;
1 2000 11 1 1000
2 2000 11 1 2000
4 2000 12 1 4000
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
input id year reg death sex incs;
datalines;
1 2000 11 0 1 1000
1 2001 12 0 1 1000
1 2002 11 0 1 1000
1 2003 11 0 1 1000
2 2000 11 1 1 2000
2 2001 12 1 1 2000
2 2002 13 1 1 2000
2 2003 14 1 1 2000
4 2000 12 . 1 4000
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I'd like to have a dataset like want.&lt;/P&gt;&lt;P&gt;The logic is that I want to keep IDs only from have2, but want to keep all person-year information for the IDs in have1. Except for the reg variable, sex and incs are time-invariant information, so I want to have the same values for all years, but in case of reg it's all changing over years, so I want to keep information from have1.&amp;nbsp; Meanwhile, there may be some IDs only shown in have2, in that case, I want to keep only the first row (as shown in have2) not making other years.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="ms-editor-squiggler"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Wed, 10 Feb 2021 17:51:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/join-or-merge-by-using-some-information/m-p/718330#M222295</guid>
      <dc:creator>Lily07</dc:creator>
      <dc:date>2021-02-10T17:51:09Z</dc:date>
    </item>
    <item>
      <title>Re: join or merge by using some information</title>
      <link>https://communities.sas.com/t5/SAS-Programming/join-or-merge-by-using-some-information/m-p/718357#M222313</link>
      <description>This code seems to give me the want dataset . Take a look.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Data thewant;&lt;BR /&gt;	merge have1(in=in1) &lt;BR /&gt;		  have2(in=in2);&lt;BR /&gt;	by id;&lt;BR /&gt;if  in2;&lt;BR /&gt;run;</description>
      <pubDate>Wed, 10 Feb 2021 19:09:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/join-or-merge-by-using-some-information/m-p/718357#M222313</guid>
      <dc:creator>CarmineVerrell</dc:creator>
      <dc:date>2021-02-10T19:09:54Z</dc:date>
    </item>
    <item>
      <title>Re: join or merge by using some information</title>
      <link>https://communities.sas.com/t5/SAS-Programming/join-or-merge-by-using-some-information/m-p/718373#M222322</link>
      <description>&lt;P&gt;According to ID=4 wanted output it seems that you select DEATH only from have1 and neglect it from have2. Try next code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  create table want as
  select a.ID, a.year, a.reg, a. sex, a.incs,
            b.death
  from have2 as a
  left join have1 as b
  on a.ID = b.ID;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 10 Feb 2021 19:45:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/join-or-merge-by-using-some-information/m-p/718373#M222322</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2021-02-10T19:45:18Z</dc:date>
    </item>
  </channel>
</rss>

