<?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: Self join in SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Self-join-in-SAS/m-p/396904#M95880</link>
    <description>&lt;P&gt;Seems simple.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql ;
  create table want as 
    select a.*,b.salary as msalary
    from have a left join have b
    on a.mid = b.eid
    where a.salary &amp;gt; b.salary and not missing(b.salary)
  ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;Obs    Eid    Mid    Salary    msalary

 1      8      3      22624     12274
 2      7      5      11532     10285
 3      4      7      47687     11532
&lt;/PRE&gt;</description>
    <pubDate>Mon, 18 Sep 2017 18:20:13 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2017-09-18T18:20:13Z</dc:date>
    <item>
      <title>Self join in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Self-join-in-SAS/m-p/394631#M95117</link>
      <description>&lt;P&gt;Hi All&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Recently i attended an interview and the interviewer asked me a really tricky question which i am not able to solve till yet , kindly provide a solutions for this&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The questions is like this ....&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i have to take out the employees&amp;nbsp;whose salary is morethan their manager's salary&lt;/P&gt;&lt;P&gt;Note: the salary column refers to the employee's salary and the manager ID referes to the manager of the employee&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nb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id>https://communities.sas.com/t5/SAS-Programming/Self-join-in-SAS/m-p/394631#M95117</guid>
      <dc:creator>soham_sas</dc:creator>
      <dc:date>2017-09-11T11:04:08Z</dc:date>
    </item>
    <item>
      <title>Re: Self join in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Self-join-in-SAS/m-p/394640#M95121</link>
      <description>&lt;P&gt;And what can you not do here? &amp;nbsp;What about:&lt;/P&gt;
&lt;PRE&gt;proc sql;  
  create table WANT as 
  select * 
  from   HAVE
  where SALARY &amp;gt; (select SALARY from HAVE where MANAGER_ID=EMPLOYEE_ID);
quit;&lt;/PRE&gt;
&lt;P&gt;Of course that assumes there is only one record per manager/employee (all I can assume from what you posted). &amp;nbsp;Basically you merge on the manager data based on the two ids and compare, can do the same in datastep.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2017 11:25:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Self-join-in-SAS/m-p/394640#M95121</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-09-11T11:25:56Z</dc:date>
    </item>
    <item>
      <title>Re: Self join in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Self-join-in-SAS/m-p/396882#M95868</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9&lt;/a&gt;by using this code the employee Id 1 ,2 and 4 is coming , but the required result is 4,7 and 8&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;as 4's manager is 7 and 4's salary is more than 7's salary and like wise for emp_ID 7 and 8&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;please help for the same as i am stuck on this to get the logic of how to resolve this issue&lt;/P&gt;</description>
      <pubDate>Mon, 18 Sep 2017 17:23:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Self-join-in-SAS/m-p/396882#M95868</guid>
      <dc:creator>soham_sas</dc:creator>
      <dc:date>2017-09-18T17:23:20Z</dc:date>
    </item>
    <item>
      <title>Re: Self join in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Self-join-in-SAS/m-p/396904#M95880</link>
      <description>&lt;P&gt;Seems simple.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql ;
  create table want as 
    select a.*,b.salary as msalary
    from have a left join have b
    on a.mid = b.eid
    where a.salary &amp;gt; b.salary and not missing(b.salary)
  ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;Obs    Eid    Mid    Salary    msalary

 1      8      3      22624     12274
 2      7      5      11532     10285
 3      4      7      47687     11532
&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Sep 2017 18:20:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Self-join-in-SAS/m-p/396904#M95880</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-09-18T18:20:13Z</dc:date>
    </item>
    <item>
      <title>Re: Self join in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Self-join-in-SAS/m-p/396909#M95884</link>
      <description>&lt;P&gt;Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt; !!! you made my day &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a ton (Y)&lt;/P&gt;</description>
      <pubDate>Mon, 18 Sep 2017 18:44:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Self-join-in-SAS/m-p/396909#M95884</guid>
      <dc:creator>soham_sas</dc:creator>
      <dc:date>2017-09-18T18:44:01Z</dc:date>
    </item>
  </channel>
</rss>

